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
[==========] Running 451 tests from 22 test cases. | |
[----------] Global test environment set-up. | |
[----------] 5 tests from LibraryInit | |
[ RUN ] LibraryInit.Basic | |
[ OK ] LibraryInit.Basic (0 ms) | |
[ RUN ] LibraryInit.UnexpectedCleanup | |
[ OK ] LibraryInit.UnexpectedCleanup (0 ms) | |
[ RUN ] LibraryInit.Nested | |
[ OK ] LibraryInit.Nested (0 ms) | |
[ RUN ] LibraryInit.BasicChannelInit |
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
package helper | |
// Call this function with User Agent header | |
func UaVersion(agent string) (string, string) { | |
var bytes []byte = make([]byte, len(agent)) | |
copy(bytes[:], agent) | |
return _uaVersion(bytes) | |
} | |
func extractVersion(fc byte, version string, lastversion *string) string { |
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
// Author: Dron Rathore <dron(.)rathore[(@)]G-Mail> | |
// A modified C++ implementation for Binary Search Tree | |
// Every node keeps a parent node ref to help the deletion | |
// in Θ(log(n)) complexity. | |
// This is no rocket science, same can be acheived with | |
// double pointers where you perform a look ahead search in | |
// the tree in case of deletion so you have parent of the | |
// Right Subtree's largest node which comes handy. |
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
package main | |
import "os" | |
import "text/tabwriter" | |
import "regexp" | |
import "fmt" | |
func main(){ | |
// silent the groups to eliminate redundant data in match | |
var r = compileRegex("/:name/:service/:id(?:[0-9]{0,3})") | |
var regex = r.FindStringSubmatch("/api/buy/123") |
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 | |
# Browsing directories on mac creates .DS_STORE and further | |
# it create similar files for any file you open | |
# it is annoying to see such files in a github repo folder and often | |
# we end up pushing them in our codebase | |
# so here is a one liner solution to remove .DS_STORE and other ._files from git | |
# run junk for non git repo, or cg for git repo, you can add this in your .bash_profile too. | |
# Add the below lines in your .bash_profile, run source ~/.bash_profile and done |
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
/* | |
Generate unique IDs for Objects | |
*/ | |
( | |
function(ref){ | |
ref.__counting_tick_var = 0; | |
Object.prototype.id = function(){ | |
return ( | |
this.__counting_tick_var ? | |
this.__counting_tick_var : |
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
/* | |
Adding values in array at init using variables is faster | |
then processing individual entity | |
*/ | |
function A(options){ | |
var a = [ “something” + options.A + “more”, “second elem” + options.B + “Yo!”] | |
return A; | |
} | |
function B(options){ | |
var a = []; |
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
/* | |
Sample from MDN | |
*/ | |
var start = null; | |
var element = document.getElementById("SomeElementYouWantToAnimate"); | |
function step(timestamp) { | |
if (!start) start = timestamp; | |
var progress = timestamp - start; | |
element.style.left = Math.min(progress/10, 200) + "px"; |
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
/* | |
Law: clearInterval = clearTimeout | |
*/ | |
var a = setTimeout(function(){console.log(1)}, 100); | |
clearInterval(a); | |
var b = setInterval(function(){console.log(1)}, 100); | |
clearTimeout(b); | |
/* | |
Nothing will be logged on console! | |
We cleared the timers! |
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
var time = Date.now(); | |
setTimeout(function(){console.log("I was fired after: ", Date.now()-time, "ms")}, 1); | |
/* | |
Output = I was fired after: 1 ms | |
*/ |
NewerOlder