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
<?php | |
class HashSet | |
{ | |
// PHP arrays are organized trees under the hood, also php provides better api's for dealing with keys. | |
// Hence we will use an arrays use it's keys for storing our nodes. Note PHP Arrays are always associative arrays. | |
private $set = []; | |
public function __construct($keys = []) |
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
/** | |
* Get the date and days within a week from week number. | |
* eg: date range for 8th week in 2013 is 17th Feb to 23rd Feb. This | |
* code snippet will give you. | |
* | |
* It is not my code completely, Bit of modification from something | |
* i found on net. Cant find it anymore so keeping a backup. | |
* | |
* @param {[Integer]} weekNo [From week 1 to Week 52/53 based on the system date setting] | |
* @return {[Date]} [description] |
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
#!/usr/bin/env bash | |
# shellcheck disable=SC2034,SC2086,SC2155,SC2001,SC2048 | |
# | |
# Search file contents (by file extension) for the specified search term. | |
# | |
# grep options: | |
# | |
# -i Perform case insensitive matching. | |
# −r Recursively search subdirectories listed. |
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
# Some youtube-dl shortcuts and workarounds. | |
# Download MP3 | |
alias youtube-dl-mp3="youtube-dl --extract-audio --audio-format mp3 " | |
# Youtube playlist which is organised in folders and Videos are numbered. | |
# use youtube-dl-playlist -f 22 <link> | |
alias youtube-dl-playlist='youtube-dl -o "./%(playlist_title)s/%(playlist_index)s_%(title)s.%(ext)s" ' | |
# Youtube-dl to download from hotstar. |
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
# https://superuser.com/questions/1310825/how-to-remove-old-version-of-installed-snaps/1330590#1330590 | |
# https://www.linuxuprising.com/2019/04/how-to-remove-old-snap-versions-to-free.html | |
#!/bin/bash | |
# Removes old revisions of snaps | |
# CLOSE ALL SNAPS BEFORE RUNNING THIS | |
set -eu | |
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' | | |
while read snapname revision; do |
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
// Kotlin have sumBy:Int and sumByDouble:Double but many of us work with Long which is missing. | |
// This is an implementation based on stdlib for sumbydouble | |
// Save this in your util to make this accessable. | |
inline fun <T> Iterable<T>.sumByLong(selector: (T) -> Long): Long { | |
var sum = 0L | |
for (element in this) { | |
sum += selector(element) | |
} | |
return sum | |
} |
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
{ | |
"files": | |
{ | |
"Angular JS": "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.js", | |
"Backbone.js": "http://backbonejs.org/backbone.js", | |
"CSS-reset": "http://meyerweb.com/eric/tools/css/reset/reset.css", | |
"Chart.js": "https://raw.githubusercontent.com/nnnick/Chart.js/master/Chart.min.js", | |
"Exoskeleton": "https://github.com/paulmillr/exoskeleton/releases/download/0.6.3/exoskeleton.min.js", | |
"Favicon.js": "https://raw.githubusercontent.com/ejci/favico.js/master/favico-0.3.5.min.js", | |
"HTML5_SQL.js": "http://html5sql.com/js/html5sql.js", |
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
Show hidden characters
// Place your key bindings in this file to override the defaults | |
// Make sure you disable/replace old keybindings or else Code can misbehave. | |
// Use "-" in command if you need to disable any keybinding. | |
// All keybindings must be either scoped or unique. | |
[ | |
// Setup advanced-new-file - Need to make my own one day | |
{ | |
"key": "ctrl+n", | |
"command": "extension.advancedNewFile" |
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
// Brightness math based on: | |
// http://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx | |
$red-magic-number: 241; | |
$green-magic-number: 691; | |
$blue-magic-number: 68; | |
$brightness-divisor: $red-magic-number + $green-magic-number + $blue-magic-number; | |
@function sqrt ($r) { | |
// http://www.antimath.info/css/sass-sqrt-function/ |
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
<?php | |
/** | |
* A more complete implementation of Java's import statement. For `PHP >=5.0, <=7` | |
* | |
* While we do not need it in modern projects, I found this to be really | |
* helpful for teaching purposes. | |
* | |
* This is for teaching purposes only. In real life, composer and namespacing is the way to go. |