Thursday, August 4, 2016

Fix Integrated Webcam stopped working in Windows 10

So I have been using windows 10 and have troubles with using the integrated webcam for my Dell Studio 1558 Laptop. The camera would just stop working and I learned how to fix it.

For the fix, go to the device manager and see if the integrated webcam is listed under imaging devices. For my case it was not listed there, however I could see a couple of "Other Devices" and an ambiguous looking device under "Universal Serial Bus Controllers". What I did is to uninstall ALL devices listed under these categories one by one and restarted the computer. The camera worked fine after that!

Good luck!

Saturday, June 25, 2016

Munir Niazi

اس شہرِ سنگ دل کو جلا دینا چاہیے​
پھر اس کی خاک کو بھی اُڑا دینا چاہیے​
ملتی نہیں پناہ ہمیں جس زمین پر​
اک حشر اس زمیں پہ اٹھا دینا چاہیے​
حد سے گزر گئی ہے یہاں رسمِ قاہری​
اس دہر کو اب اس کی سزا دینا چاہیے​
اک تیز رعد جیسی صدا ہر مکان میں​
لوگوں کو ان کے گھر میں ڈرا دینا چاہیے​
گُم ہو چلے ہو تم تو بہت خود میں اے منیر​
دنیا کو کچھ تو اپنا پتا دینا چاہیے​

Inspiration: Naeem Bukhari


Inspiration: Dr. Adib Rizvi














Saturday, May 21, 2016

مقدمہ الفاظ

Words on trial
(منظرِ عدالتِ الفاظ)
عدالت بھری تھی لفظوں سے 
جرم بھی
مجرم بھی
مدعا بھی
واقعہ بھی
معصوم اور
ملزوم بھی
قاتل اور
مقتول بھی
سچی باتیں
جھوٹے بول
سب پیش ہوئے
وکیل بڑھے
گواہوں سے
سوال ہوئے
کٹہرے میں
قانون کے
معانی کھلے
سزا تو جزا میں نہ بدل سکی لیکن
منصف نے یہ فیصلہ دیا
"!حرفِ گناہ بے گناہ ہے"

(Fayyaz Minhas)

Monday, February 8, 2016

Bibliography or Reference Management in LaTeX using Zotero Standalone

I use LaTeX for writing paper but it can be rather difficult, especially for beginners, to add citations and Bibliography. For this purpose I use Zotero Standalone which is an awesome software for reference management. It has a plugin for MS Word. However, for LaTeX, the citations need to be added manually. There are some automated tools available but I could not find an easy to use or dependable one. So I describe a process that you can use to add citations and bibliography directly in your LaTeX document from Zotero.

Adding Citations

Adding citations manually in LaTeX from Zotero is a pain. However, the process described below will make it a breeze for you. It contains the following steps:


  • Installing bibtex-citep.js

Download the bibtex-citep.js translator from here (http://pastebin.com/UNVexqKc). Great work by these guys! This translator will allow you to easily cite the paper using a simple drag-drop procedure in your LaTeX file. However, first we need to install it. Place the downloaded file in the "translators" folder in Zotero standalone.  You can access this folder by opening Zotero Standalone and navigating as (see image below): Tools > Preferences > Advanced (tab) > File and Folders (sub tab) > Show Data Directory. This data directory contains the "translators" folder.




  • Restart Zotero
  • For exporting citations as \cite{...} from Zotero, you would need to set the export mode of Zotero to bibtex-citep. You can do this as follows: In Zotero, Go to Tools > Preferences > Export (tab) > Select Export Format (drop down menu), select "bibtext-citep" and click OK.
  • Now you can add citations from Zotero directly. To do this you can select a paper in Zotero and drag-drop it in your opened LaTeX file in a text editor and it will create a \citep{...} citation automatically. If you want \cite{...} or \citet{...} you can manually edit the name of the field in your text editor. An alternative way is to click on the paper in Zotero to select it and then press Ctrl+shift+C to export the citation to the clipboard which can then be pasted anywhere you like.

Adding Bibliography

Adding bibliography requires a simple export of the Zotero Library as BibLaTeX. This can be easily accomplished by Clicking on File > Export Library. An "export" dialog will appear and you can simply select "BibLateX" as the format and click OK.It will ask you where to save the bib file and what name to give it. You can choose any name (say, "mybib.bib") for it and save it in the directory containing your LaTeX sources. You can then simply add "\bibliography{mybib}" to your LaTeX file and compile your LaTeX source.

If you do not want to export your whole Zotero library, you can choose to create a collection or add specific tags in Zotero to the papers that you cite or use in your LaTeX document and then export only that collection by right clicking on the collection in the left pane of Zotero Standalone. You can read more about Collections and tags hereAlternatively you can use the following python script to get a cleaned up bib file containing the bib entries for the citations you have in your paper. It takes the zotero exported bib file and a bbl file generated by LaTeX from the zotero bib file to create another bib file containing only the cited entries. This output file can then be used in your LaTeX document.

Enjoy!


# -*- coding: utf-8 -*-
"""
Created on Sun Jan 18 12:23:36 2015

@author: Afsar
"""
from pyparsing import nestedExpr
import re

bbl = '.\paper.bbl' #input bbl file
bibin = '.\mybib.bib' #zotero bib file 
bibout = 'outbib.bib' #output file containing only the citations used

B = []
with open(bbl,'r') as fbbl:
    for ln in fbbl:
        if 'bibitem' in ln:
            B.append(ln[ln.find('{')+1:-2])

fields = []
i=-1
with open(bibin,'r') as fbibin:
    for ln in fbibin:
        if ln and ln[0] == '@':
            i+=1
            fields.append('')
        if i<0:
            continue
        fields[i]+=ln

entries = {}       
for f in fields:
    hdr = f.split(',')[0].split('{')[1]
    entries[hdr]= f

with open(bibout,'w') as fout:
    for b in B:
        try:
            fout.write(entries[b])
        except KeyError as e:

            print e,':',b