Skip to content

Instantly share code, notes, and snippets.

View evandrix's full-sized avatar
💭
offline

evandrix evandrix

💭
offline
View GitHub Profile
@evandrix
evandrix / invsqrt.c
Created October 15, 2011 21:57
Quake: Inverse Sqrt
float InvSqrt(float x){
float xhalf = 0.5f * x;
int i = *(int*)&x; // store floating-point bits in integer
i = 0x5f3759d5 - (i >> 1); // initial guess for Newton's method
x = *(float*)&i; // convert new bits into float
x = x*(1.5f - xhalf*x*x); // One round of Newton's method
return x;
}
@evandrix
evandrix / MAIN112.java
Created September 3, 2011 00:56
algorithm - SPOJ Problemset (Classical): 9386. Re-Arrange II #[MAIN112] @ http://stackoverflow.com/questions/7276291/spoj-problemset-classical-9386-re-arrange-ii-main112
import static java.util.Arrays.*;
import static java.lang.Math.*;
import java.io.*;
import java.lang.*;
import java.util.*;
class main112 {
private int[] A, C;
private int N;
@evandrix
evandrix / scrape.js
Created August 21, 2011 21:49
Node.io implementation to scrape puzzles from 'http://gurmeet.net/puzzles/'
var nodeio = require('node.io');
var options = {
benchmark: false,
timeout: 999, //Timeout after 10 seconds
max: 1, //Run xx threads concurrently (when run() is async)
retries: 5, //Threads can retry x times before failing
auto_retry: false
};
exports.job = new nodeio.Job(options, {
init: function() { },
This grid shows the restaurants in Hamburg which have E la Carte units ("Prestos") installed in
them. The Ps in the grid represent restaurants with Prestos installed ("Prestorants"). Os
represent restaurants without prestos.
Alyssa P. Hacker from the E la Carte ops team wants to count the number of restaurants in the
largest contiguous rectangular block of Prestorants. What is the number that she comes up with?
Answer: __44__
top-left corner: (15, 5742)
@evandrix
evandrix / gist:1130954
Created August 7, 2011 23:57
Programmer's Links: Basics
@ http://altdevblogaday.com/2011/08/06/demise-low-level-programmer/
Floating Point Numbers
They are very useful but often used in situations where they simply don’t suit the solution the programmer is attempting to write. The following links should provide some background and info on where they are not so useful, what the pitfalls are and sometimes even how to avoid them.
http://www.cprogramming.com/tutorial.html#fptutorial
http://www.johndcook.com/blog/2009/04/06/numbers-are-a-leaky-abstraction/
http://www.codeproject.com/KB/recipes/float_point.aspx
http://drdobbs.com/184402741?pgno=4
http://users.tkk.fi/jhi/infnan.html
@evandrix
evandrix / gist:1124922
Created August 4, 2011 10:30
Python String API
# a look at strings and methods
# tested with Python23 vegaseat 23jan2005
print "Fill an empty string:"
empty_string = ""
for k in range(65, 91):
empty_string += chr(k)
print empty_string
print "\nOriginal string (California humor):"
@evandrix
evandrix / solution.pl
Created July 29, 2011 22:44 — forked from dmn001/Dropbox-Diet Solution
Dropbox Challenge - 3 The Dropbox Diet
#!/usr/bin/perl
use strict;
# dmn001 <at> gmail
# 31/01/2011
my %pos;
my %neg;
my $num_lines = <STDIN>;
while (<STDIN>){
@evandrix
evandrix / solution.py
Created July 29, 2011 22:33
Dropbox Challenge - 1 Packing Your Dropbox
#!/usr/bin/python
"""
Amar Pai ([email protected])
Solution to Dropbox challenge - Packing Your Dropbox
http://www.dropbox.com/jobs/challenges#packing-your-dropbox
I've had this problem on the brain and have been unable to
stop thinking about it, so I finally hacked out a rudimentary
Netragard’s Hacker Interface Device (HID). Category: Hardware, Healthcare,
penetration test, Realistic Threat, Research, Software, Total Infrastructure
Compromise / Tag: Adrian Crenshaw, Healthcare, malware, Mouse, Netragard,
penetration test, Prion, Teensy, USB / Add Comment Author: Adriel Desautels We
(Netragard) recently completed an engagement for a client with a rather restricted
scope. The scope included a single IP address bound to a firewall that offered no
services what so ever. It also excluded the use of social attack vectors based on
social networks, telephone, or email and disallowed any physical access to the
campus and surrounding areas. With all of these limitations in place, we were
tasked with penetrating into the network from the perspective of a remote threat,
How to use Google Charts API with 6 examples
Few months ago I had a good look into Google Charts API and it was great! If you are not aware, Google Charts API basically allows you to create pretty graphs simply by using an URL with correct parameters specified. It is fairly flexible, with many things you can change and customise - which is where it becomes bit complicated. It is quite easy to generate a chart, but it wasn't as easy to generate the exact chart I needed. So below are 6 examples charts with explanations and tips that will hopefully help you understand Google Charts better.
A few notes before I start
The data/labels for all the graphs here have no meaning at all - just examples that I have come up with.
I'll explain each parameter probably only once (since they are generally the same across all graphs). If something is different or special I'll explain it again.
If you have any other tips/hints please share