Skip to content

Instantly share code, notes, and snippets.

View meadhikari's full-sized avatar
🏠
Working from home

Bikram Adhikari meadhikari

🏠
Working from home
View GitHub Profile
@meadhikari
meadhikari / Must be a correct way
Created February 8, 2012 10:14
Javascript Novice Question
// this clearly is not the correct way of doing this, what must I be doing
pos1 = document.getElementById('pos1').value;
pos2 = document.getElementById('pos2').value;
pos3 = document.getElementById('pos3').value;
pos4 = document.getElementById('pos4').value;
pos5 = document.getElementById('pos5').value;
pos6 = document.getElementById('pos6').value;
pos7 = document.getElementById('pos7').value;
pos8 = document.getElementById('pos8').value;
pos9 = document.getElementById('pos9').value;
@meadhikari
meadhikari / gist:2015638
Created March 11, 2012 08:47
What am I doing wrong
We couldn’t find that file to show.
@meadhikari
meadhikari / kantipur.py
Created March 17, 2012 19:28
Pdf downloader
import datetime
#import urllib2
import re
import os
from pyPdf import PdfFileWriter, PdfFileReader
from urllib2 import Request, urlopen
from StringIO import StringIO
#date in the url format
now = datetime.datetime.now()
@meadhikari
meadhikari / stringfetch.java
Created September 6, 2012 09:17
Android Out of Memory, How to Optimize
StringBuilder response = new StringBuilder();
String jsonString;
URL url;
HttpURLConnection httpconn;
try {
url = new URL("http://backend-newsinamap.appspot.com");
httpconn = (HttpURLConnection) url.openConnection();
if (httpconn.getResponseCode() == HttpURLConnection.HTTP_OK)
{
@meadhikari
meadhikari / gist:3873415
Created October 11, 2012 16:03
First common lisp function
;Add all the natural numbers below one thousand that are multiples of 3 or 5.
(defun sum-to-last (x)
(cond ((eql x 0)
0)
(t
(let ((mod3 (eql (mod x 3) 0))
(mod5 (eql (mod x 5) 0))
)
(cond ((or mod3 mod5)
(+ x (sum-to-last (1- x)))
@meadhikari
meadhikari / tpb.js
Created November 15, 2012 12:19
Get Torrent link on all Pirate bay Pages.
// ==UserScript==
// @name Get Torrent link on all piratebay link
// @description Sets a torcache link to all torrent files from torcache
// @namespace http://googlesystem.blogspot.com
// @include http://thepiratebay.se/torrent/*
// @include https://thepiratebay.se/torrent/*
// @match http://thepiratebay.se/torrent/*
// @match https://thepiratebay.se/torrent/*
// @author Bikram
// @version 1.4.10
@meadhikari
meadhikari / list_reduction.py
Created November 29, 2012 18:16
Reduce the list and add to why on every deletion
my_input = [{'why': [u'The Matrix Revolutions'], 'title': u'The Matrix'},
{'why': [u'The Matrix Revolutions'], 'title': u'Inception'},
{'why': [u'The Matrix'], 'title': u'The Matrix Revolutions'},
{'why': [u'The Matrix'], 'title': u'Inception'},
{'why': [u'Saving Private Ryan'], 'title': u'The Hurt Locker'},
{'why': [u'Black Hawk Down'], 'title': u'Saving Private Ryan'},
{'why': [u'Black Hawk Down'], 'title': u'The Kingdom'},
{'why': [u'Black Hawk Down'], 'title': u'The Hurt Locker'},
{'why': [u'A Walk To Remember'], 'title': u'The Notebook'},
{'why': [u'Cast Away'], 'title': u'Forrest Gump'},
13/02/17 18:19:19 INFO util.NativeCodeLoader: Loaded the native-hadoop library
13/02/17 18:19:19 WARN snappy.LoadSnappy: Snappy native library not loaded
13/02/17 18:19:19 INFO mapred.FileInputFormat: Total input paths to process : 7
13/02/17 18:19:19 INFO mapred.JobClient: Running job: job_local_0001
13/02/17 18:19:20 INFO util.ProcessTree: setsid exited with exit code 0
13/02/17 18:19:20 INFO mapred.Task: Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@28ab54eb
13/02/17 18:19:20 INFO mapred.MapTask: numReduceTasks: 1
13/02/17 18:19:20 INFO mapred.MapTask: io.sort.mb = 100
13/02/17 18:19:20 WARN mapred.LocalJobRunner: job_local_0001
java.lang.OutOfMemoryError: Java heap space
with open("Data.txt") as f:
content = ast.literal_eval(f.readlines())
@meadhikari
meadhikari / gist:5460813
Last active December 16, 2015 16:09
ead Urls and I download web page content somewhere locally on HDD
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;