Skip to content

Instantly share code, notes, and snippets.

var phantom=require('node-phantom');
phantom.create(function(err,ph) {
ph.createPage(function(err,page) {
page.setFn('onInitialized', function() {
console.log("In initialized");
page.evaluate(function(domContentLoadedMsg) {
document.addEventListener('DOMContentLoaded', function() {
window.callPhantom('DOMContentLoaded');
@souri
souri / casper_dynamic.js
Created May 20, 2013 18:53
Scraping dynamic ajax content with CasperJS
var fs = require('fs'),
casper = require('casper').create({
verbose: true,
logLevel: "debug",
pageSettings: {
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.21 (KHTML, like Gecko) Chrome/25.0.1349.2 Safari/537.21'
},
clientScripts: ['jquery.min.js']
});
@souri
souri / sudokusolver.cpp
Created May 23, 2013 10:13
Solve sudoku
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
using namespace std;
int in[9][9] = {{9, 0, 5, 0, 0, 7, 8, 0, 1},
{0, 0, 6, 5, 0, 0, 3, 0, 0},
{0, 3, 0, 6, 0, 9, 0, 0, 0},
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
"elf64-x86-64")
OUTPUT_ARCH(i386:x86-64)
ENTRY(_start)
SEARCH_DIR("/usr/x86_64-linux-gnu/lib64"); SEARCH_DIR("=/usr/local/lib/x86_64-linux-gnu"); SEARCH_DIR("=/usr/local/lib64"); SEARCH_DIR("=/lib/x86_64-linux-gnu"); SEARCH_DIR("=/lib64"); SEARCH_DIR("=/usr/lib/x86_64-linux-gnu"); SEARCH_DIR("=/usr/lib64"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
MEMORY
{
writablemem (wx) : ORIGIN = 0x0000000000400270, LENGTH = 0x72D
}
@souri
souri / disable-service.sh
Created July 2, 2014 18:35
Disable Ubuntu services
#!/bin/sh
# Abort immediately if any command exists with a non-zero code.
set -e
# Do we need 'sudo'?
sudo=
if [ "$( id -u )" != 0 ]; then
sudo='sudo'
fi
@souri
souri / -
Created January 22, 2015 15:36
{
"type": "mongodb",
"mongodb": {
"db": "mydb76",
"collection": "mycollec76",
"options": {
"exclude_fields": ["exclude-1", "exclude-2"]
}
},
"index": {
@souri
souri / a.rb
Created January 22, 2015 15:37
ElasticSearch exclude example
{
"type": "mongodb",
"mongodb": {
"db": "mydb76",
"collection": "mycollec76",
"options": {
"exclude_fields": ["exclude-1", "exclude-2"]
}
},
"index": {
@souri
souri / a.rb
Created February 6, 2015 14:52
$('#searchinput').autocomplete({
source: function(req,res) {
console.log("req:" + req.term)
$.ajax({
// url: "http://souri-mediaserver.ddns.net:5000/ac/"+req.term,
url: "http://192.168.1.111:5000/ac/" + link[3]+ "/" +req.term,
dataType: "jsonp",
type: "GET",
data: {
term: req.term
@souri
souri / a.rb
Created February 19, 2015 17:39
Dim dialog As New OpenFileDialog()
If DialogResult.OK = dialog.ShowDialog Then
TextBox1.Text = dialog.FileName
End If
@souri
souri / colonscopy_bracketing
Created March 18, 2015 09:28
reetika's work
import math
import pprint
# import matplotlib.pyplot as plt
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from rotanimate import rotanimate
import numpy as np