Skip to content

Instantly share code, notes, and snippets.

@prasincs
prasincs / alerts.js
Created May 30, 2014 18:21
simple alert
alert('hello');
@prasincs
prasincs / replaces_by_ref.js
Created April 24, 2014 01:15
String Interpolation - from object
function replaceAll(str, obj){
//Based on http://jsfiddle.net/sc0ttyd/q7zyd/ and corresponding stackoverflow post
var stringToRef = function (object,reference) {
function arrayDeref(o, ref, i) {
return !ref ? o : (o[ref.slice(0, i ? -1 : ref.length)]);
}
function dotDeref(o, ref) {
return !ref ? o : ref.split('[').reduce(arrayDeref, o);
}
return reference.split('.').reduce(dotDeref, object);
import csv,sys
if len(sys.argv) < 3:
print "Need input and output filenames"
sys.exit(0)
inFile = open(sys.argv[1], "rU")
reader = csv.DictReader(inFile)
destFieldNames = reader.fieldnames
@prasincs
prasincs / json_marshalling.go
Last active December 20, 2015 01:29
Golang hacks/experiments
package main
import (
"encoding/json"
"time"
"fmt"
"strconv"
)
type jsonTime time.Time
@prasincs
prasincs / balanced_smileys.py
Created January 27, 2013 17:00
Facebook Hacker Cup 2013 qualification solutions
import sys
from collections import Counter
import string,re
input_stream = sys.stdin
cases = int(input_stream.readline())
def is_understandable(input_str):
_string = input_str.replace(':)', '').replace(':(', '')
stack = []
for char in _string:
@prasincs
prasincs / disable-win-key.reg
Created January 24, 2013 20:58
disables Windows key capture in Windows -- was bugging me with XMonad.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"NoWinKeys"=dword:00000001
@prasincs
prasincs / foscam_docs.md
Last active June 10, 2023 08:54
FOSCAM Documentation

Adapted from http://www.digitalham.co.uk/web/development/embedding-cctv/ipcam-cgi-sdk/

AFAIK, everything is based on the CGI scripts below, there might be ways to get the streams but I believe it's doable without hacking the firmware and stuff. All functions should be accessible via GET and POST methods.

ACL groups:visitor、operator and Administrator.

Upgrade_firmware.cgi and upgrade_htmls.cgi only support post method,others cgi only support get method.

next_url:

source :rubygems
gem 'bundler'
# Rake
gem 'rake'
# Web container
gem 'rack'
#Newbie programmer
# Exp: -> first exercise in recursion
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
@prasincs
prasincs / compilePosit.sh
Created May 10, 2012 01:24
Compile Script for POSIT -- written in Fall 2009
#!/bin/bash
ANT_EXEC=/usr/bin/ant
JAVA_HOME=/usr/lib/jvm/ia32-java-1.5.0-sun
JAVA_EXEC=$JAVA_HOME/bin/java
ANT_BUILD_TARGET=debug
HOME=/home3/hfoss/hfoss_posit/build_dir/
POSIT_DIR=/home3/hfoss/hfoss_posit/build_dir/posit-android
PROJECT_ID=$1
DOWNLOAD_DIR=/home3/hfoss/hfoss_posit/build_dir/downloads
PROJECT_DIR=$DOWNLOAD_DIR/projects/$PROJECT_ID/