Skip to content

Instantly share code, notes, and snippets.

View smtchahal's full-sized avatar

Sumit Chahal smtchahal

View GitHub Profile
@bradtraversy
bradtraversy / typescript-crash.ts
Last active May 3, 2024 13:32
Basic intro to TypeScript (From YouTube Crash Course)
// Basic Types
let id: number = 5
let company: string = 'Traversy Media'
let isPublished: boolean = true
let x: any = 'Hello'
let ids: number[] = [1, 2, 3, 4, 5]
let arr: any[] = [1, true, 'Hello']
// Tuple
@e0en
e0en / base64sha384.zsh
Created October 27, 2018 09:56
Calculate base64-encoded SHA-384 hash of a file. Useful when you need to fill "integrity" field of HTML resources.
# calc base64-encoded sha384 hash of a file
base64sha384 () {
openssl dgst -sha384 -binary < $1 | openssl enc -base64
}
anonymous
anonymous / untrusted-lvl1-solution.js
Created December 24, 2015 17:15
Solution to level 1 in Untrusted: http://alex.nisnevich.com/untrusted/
/*****************
* cellBlockA.js *
*****************
*
* Good morning, Dr. Eval.
*
* It wasn't easy, but I've managed to get your computer down
* to you. This system might be unfamiliar, but the underlying
* code is still JavaScript. Just like we predicted.
*
var defaultTitle = document.title;
// subscribe to visibility change events
document.addEventListener('visibilitychange', function () {
// fires when user switches tabs, apps, goes to homescreen, etc.
if (document.visibilityState === 'hidden') {
document.title = 'Baby, Come Back!'
}
// fires when app transitions from prerender, user returns to the app / tab.
if (document.visibilityState === 'visible') {
@lastguest
lastguest / JSON_to_URLEncoded.js
Created July 10, 2014 17:47
Convert JavaScript object to x-www-form-urlencoded format
function JSON_to_URLEncoded(element,key,list){
var list = list || [];
if(typeof(element)=='object'){
for (var idx in element)
JSON_to_URLEncoded(element[idx],key?key+'['+idx+']':idx,list);
} else {
list.push(key+'='+encodeURIComponent(element));
}
return list.join('&');
}
@championofblocks
championofblocks / wav-mp3
Last active May 1, 2024 12:49
Command line bash to convert all wav to mp3
for i in *.wav; do lame -b 320 -h "${i}" "${i%.wav}.mp3"; done