Skip to content

Instantly share code, notes, and snippets.

View xennygrimmato's full-sized avatar

Vaibhav Tulsyan xennygrimmato

View GitHub Profile
import redis
import threading
class Listener(threading.Thread):
def __init__(self, r, channels):
threading.Thread.__init__(self)
self.redis = r
self.pubsub = self.redis.pubsub()
self.pubsub.subscribe(channels)
@xennygrimmato
xennygrimmato / fenwick_tree.py
Created April 20, 2016 11:49 — forked from robert-king/fenwick_tree.py
Python Binary Index Tree (Fenwick tree) with range updates.
__author__ = 'robert'
"""
Implementation inspired by Petr Mitrichev's blog post http://petr-mitrichev.blogspot.co.nz/2013/05/fenwick-tree-range-updates.html
and
Yoshiya Miyata's Quora answer http://qr.ae/pHhNN
"""
class Bit:
def __init__(self, n):
@xennygrimmato
xennygrimmato / infer-trace.log
Created July 30, 2016 13:51
Running infer on jetty raises an error in analyze.py
Fatal error: exception JBasics.Class_structure_error("Illegal method index (does not refer to a constant method)")
Traceback (most recent call last):
File "/usr/local/bin/infer", line 183, in <module>
main()
File "/usr/local/bin/infer", line 147, in main
capture_exitcode = imported_module.gen_instance(args, cmd).capture()
File "/usr/local/Cellar/infer/0.8.1/libexec/infer/lib/python/inferlib/capture/mvn.py", line 82, in capture
return util.run_compilation_commands(cmds, clean_cmd)
File "/usr/local/Cellar/infer/0.8.1/libexec/infer/lib/python/inferlib/capture/util.py", line 40, in run_compilation_commands
if cmd.start() != os.EX_OK:
Traceback (most recent call last):
File "/usr/local/bin/infer", line 183, in <module>
main()
File "/usr/local/bin/infer", line 147, in main
capture_exitcode = imported_module.gen_instance(args, cmd).capture()
File "/usr/local/Cellar/infer/0.8.1/libexec/infer/lib/python/inferlib/capture/mvn.py", line 80, in capture
cmds = self.get_infer_commands(util.get_build_output(self.build_cmd))
File "/usr/local/Cellar/infer/0.8.1/libexec/infer/lib/python/inferlib/capture/util.py", line 27, in get_build_output
return verbose_out_chars.split('\n')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 11943036: ordinal not in range(128)
@xennygrimmato
xennygrimmato / Hello.java
Created August 1, 2016 18:28
Java code that gives Null Pointer Exception
import java.io.*;
import java.util.*;
public class Hello {
private static String x=null, y=null;
public static void main(String[] args) {
if(x.concat(y) == "abcd") {
System.out.println("Matched");
}
@xennygrimmato
xennygrimmato / BugTrace.log
Created August 8, 2016 09:11
Running inferTraceBugs on report generated by Infer for Rhino
src/org/mozilla/javascript/NativeCallSite.java:132: error: NULL_DEREFERENCE
object cs last assigned on line 130 could be null and is dereferenced at line 132
Showing all 6 steps of the trace
src/org/mozilla/javascript/NativeCallSite.java:122: start of procedure js_toString(...)
120. }
121.
122. > private Object js_toString(Scriptable obj)
123. {
@xennygrimmato
xennygrimmato / Mod.java
Created August 9, 2016 08:01
Java code in which modulo 1 operation is being performed
public class Mod {
public int modulo_one(int x) {
int rem = x % 1;
return rem;
}
}
open! Utils
module F = Format
module L = Logging
(** backward analysis for computing set of maybe-live variables at each program point *)
module Domain = AbstractDomain.FiniteSet(Var.Set)
(* compilers 101-style backward transfer functions for liveness analysis. gen a variable when it is
@xennygrimmato
xennygrimmato / catchChecker.ml
Last active August 16, 2016 01:18
Expression to check whether a certain instruction is within a catch block
open! Utils
module F = Format
module L = Logging
module Domain = struct (* implementation of join, widen, <=, pp *)
type astate = { in_catch : bool ; seen_call : bool; }
let is_bottom _ = false
let initial = { in_catch = false; seen_call = false; }
let (<=) ~lhs ~rhs = lhs == rhs
=========== ./BANANAGLEE/BANANAUSURPER/BG2200_UPGRADE/UPGRADE/BUSURPER-2211-611.exe ===========
00000000 l df *ABS* 00000000 upgrade_pix.c
00000000 l df *ABS* 00000000 change_page_permission.c
00000000 l df *ABS* 00000000 osVersionChecking.c
=========== ./BANANAGLEE/BANANAUSURPER/BG2200_UPGRADE/UPGRADE/BUSURPER-2211-614.exe ===========
00000000 l df *ABS* 00000000 upgrade_pix.c
00000000 l df *ABS* 00000000 change_page_permission.c
00000000 l df *ABS* 00000000 osVersionChecking.c
=========== ./BANANAGLEE/BANANAUSURPER/BG2200_UPGRADE/UPGRADE/BUSURPER-2211-622.exe ===========
00000000 l df *ABS* 00000000 upgrade_pix.c