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 <algorithm> | |
template <class Iterator> | |
inline void BubbleSort(Iterator begin, Iterator end) { | |
for (Iterator i = begin; i != end; ++i) | |
for (Iterator j = begin; j < i; ++j) | |
if (*i < *j) | |
std::iter_swap(i, j); | |
} |
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 <stdio.h> | |
#include <dirent.h> | |
#include <string.h> | |
#define GREEN "\x1b[32m" | |
#define BLUE "\x1b[34m" | |
#define WHITE "\x1b[37m" | |
void Usage() { | |
fprintf(stderr, "\nUsage: exec [OPTION]... [DIR]...\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
#if __cplusplus > 199711L /// C++11 | |
#include <chrono> | |
class Timer { | |
public: | |
Timer() : beg_(clock_::now()) {} | |
void reset() { beg_ = 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
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 |
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
#!/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
[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
#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
/** 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
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; | |
}, |
OlderNewer