This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Data; | |
using System.Runtime.CompilerServices; | |
public static class ObjectExtensions { | |
public static void Dump(this Object o) { | |
Console.WriteLine("{0,-30} {1}", "Name", "Value"); | |
Console.WriteLine("-----------------------------------------------------------------"); | |
foreach (var prop in o.GetType().GetProperties()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(w) { | |
"use strict"; | |
function ajax(method, url, callback, data) { | |
return (function(x) { | |
x.onreadystatechange = function() { | |
x.readyState ^ 4 || callback(this); | |
}; | |
x.open(method, url, callback); | |
x.send(data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* File : FileSize.java | |
* Purpose : Concurrently process a filesystem sub-tree and calculate it's size | |
* Author : Shreevardhan | |
* Compilation : `javac FileSize.java` | |
* Execution : `java FileSize <path> <threads>` | |
*/ | |
import java.io.IOException; | |
import java.nio.file.*; | |
import java.nio.file.attribute.BasicFileAttributes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CRC() { | |
var table = new Array(256), /// LookUp Table for CRC | |
initial = 0xFFFFFFFF; /// Initial CRC | |
return { | |
/// Reverse a polynomial | |
reverse: function(poly) { | |
var rev = 0; | |
for(var i = 0; i < 32; i++) rev = rev << 1 | (poly >>> i) & 1; | |
return rev; | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Numerical Analysis 9th ed - Burden, Faires (Ch. 3 Natural Cubic Spline, Pg. 149) */ | |
#include <stdio.h> | |
int main() { | |
/** Step 0 */ | |
int n, i, j; | |
scanf("%d", &n); | |
n--; | |
float x[n + 1], a[n + 1], h[n], A[n], l[n + 1], | |
u[n + 1], z[n + 1], c[n + 1], b[n], d[n]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
#include <thread> | |
template <typename T = std::chrono::milliseconds> | |
class Timer { | |
typedef std::chrono::high_resolution_clock clock; | |
public: | |
Timer() : start(clock::now()) {} | |
inline void reset() { start = clock::now(); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
Param ( | |
[ValidateRange(0, 18)] [int] $idx = 0, | |
[ValidateSet("en-US", "en-IN")] [string] $mkt = "en-IN" | |
) | |
$url = "http://www.bing.com/HPImageArchive.aspx?format=js&n=1&mkt=$mkt&idx=$idx" | |
$url = "http://www.bing.com" + (Invoke-RestMethod $url).images[0].url | |
$file = (Resolve-Path "~\Pictures\BingDesktop\").Path + $url.Split('/')[-1].Split('_')[0] + ".jpg" | |
if (-NOT (Test-Path $file)) { Invoke-WebRequest $url -OutFile $file } | |
Set-ItemProperty Wallpaper -Path "HKCU:\Control Panel\Desktop" -Value $file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get day from command line (default 0) | |
[ "$#" -ne 1 ] && set -- "0" | |
# Options | |
dir=~/Pictures/BingDesktop/ # Working directory | |
day="&idx=$1" # Set day. 0 is current day, 1 is previous day, ... | |
num="&n=1" # No. of images to get | |
mkt="&mkt=en-IN" # Set required market |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Compilation : Include this file in a C program | |
* Compile with an extra flag | |
* $compiler -std=c99 $executable $program | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdarg.h> | |
#include <string.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def power(base, exp): | |
""" Fast power calculation using repeated squaring """ | |
if exp < 0: | |
return 1 / power(base, -exp) | |
ans = 1 | |
while exp: | |
if exp & 1: | |
ans *= base | |
exp >>= 1 | |
base *= base |