Skip to content

Instantly share code, notes, and snippets.

Avatar

Shai Aharoni internetbird

  • Kfar Saba, Israel
View GitHub Profile
View ES6 - let example
var list = document.getElementById("list");
for (var i = 1; i <= 5; i++) {
var item = document.createElement("LI");
item.appendChild(document.createTextNode("Item " + i));
let j = i;
item.onclick = function (ev) {
console.log("Item " + j + " is clicked.");
};
View gist:f3f01bf021dbfc2a6860
public class TemplateParser
{
public string ParseTemplate(string template, object data)
{
var tokensRegex = new Regex(@"\{{([^}]+)}}");
return tokensRegex.Replace(template, match =>
{
string tokenName = match.Groups[1].Value;
@internetbird
internetbird / AudioAPI2.html
Created Jan 29, 2015
Audio API example which plays an A minor chord
View AudioAPI2.html
<script>
var AFreq = 440;
var CFreq = 261.626;
var EFreq = 329.628;
var audioContext = new AudioContext();
var gainMix = audioContext.createGain();
gainMix.gain.value = 0.1;
@internetbird
internetbird / audioAPI.html
Created Jan 29, 2015
AudioAPI sample which play 2 notes (C & A) together
View audioAPI.html
<script>
var audioContext = new AudioContext();
var osc = audioContext.createOscillator();
var osc2 = audioContext.createOscillator();
var gainOsc = audioContext.createGain();
var gainOsc2 = audioContext.createGain();
var gainMix = audioContext.createGain();
gainOsc.gain.value = 0.1;
@internetbird
internetbird / gist:5de59e7a2a3871154a26
Created Sep 11, 2014
PhoneGap FileBorwser mock methods
View gist:5de59e7a2a3871154a26
var getCurrentDirEntriesMock = function (onSuccess) {
var entries = [];
if (currentDir.name == "rootDirectory") {
entries.push({ isDirectory: true, name: "dir1" });
entries.push({ isDirectory: true, name: "dir2" });
entries.push({ isFile: true, name: "file1" });
entries.push({ isFile: true, name: "file2" });
View inceasesqltimeout.sql
USE DBNAME ;
GO
EXEC sp_configure 'remote query timeout', 1000 /*Num of seconds*/ ;
GO
RECONFIGURE ;
GO
View PhoneGap Simulator.js
//For simulating PhoneGup
M.PhoneGap = {};
//getImage
M.PhoneGap.getImage = function (callback) {
callback("someImage" + (new Date()).getMilliseconds() + ".jpg");
};
//mapFileName
View regex.cs
//Phone number regex
//A simple match for up to 10 digits or {2-3}-{6-7}
var simplePnoneRegex = new Regex(@"^\d{2,3}(-)?\d{6,7}$");
@internetbird
internetbird / JqueryCss.js
Last active Dec 22, 2015
Ugly use of Jquery.append. Any Ideas on how to improve this?
View JqueryCss.js
function drawZoomButtons() {
for (var i = 1; i <= numOfTicks; i++) {
var position = (canvas.width / numOfTicks) * i;
(function (sectionNum) {
var zoomInBtn = $("<div>")
.addClass("timelineZoomInButton")