Skip to content

Instantly share code, notes, and snippets.

@alok-sin
alok-sin / AdvancedWindowSnap.ahk
Created April 13, 2018 22:54 — forked from AWMooreCO/AdvancedWindowSnap.ahk
Advanced Window Snap is a script for AutoHotKey that expands upon Windows built-in window-snapping hotkeys.
/**
* Advanced Window Snap
* Snaps the Active Window to one of nine different window positions.
*
* @author Andrew Moore <[email protected]>
* @version 1.0
*/
/**
* SnapActiveWindow resizes and moves (snaps) the active window to a given position.
@alok-sin
alok-sin / fizzbuzz.php
Created November 11, 2017 23:01
FizzBuzz in php
<?php
for ($num = 1; $num <= 100; $num++) {
$result = '';
if ($num % 3 == 0) $result = 'Fizz';
if ($num % 5 == 0) $result .= 'Buzz';
echo (empty($result)) ? $num : $result;
echo '<br />';
}
@alok-sin
alok-sin / random.md
Last active July 15, 2017 01:16
Common Frontend glitches

Url populates with GET params on click:

  • This usually occurs when the button is clicked and the default behavior is left unchecked to run in the wild.
  • Solutions:
    • Add attribute type="button"
    • preventDefault()

Need to click <a> twice.

  • For me, it occurred with bootstrap attributes data-toggle. The href and data-toggle compete for your clicks. Somedays you are lucky and have a beer, somedays you cry yourself to sleep.
  • Solution: Wrap in some parent element and toggle that.
@alok-sin
alok-sin / preprocessor_fun.h
Last active September 4, 2015 09:01 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@alok-sin
alok-sin / function to getNextPermutation
Created April 27, 2015 09:20
Gives next larger (or smaller) permutation
function nextPermutation($arr)
{
$i = count($arr) - 1;
while ($i > 0 && $arr[$i - 1] >= $arr[$i]) //<= for previous permutation
$i--;
if ($i <= 0)
return false;
$j = count($arr) - 1;
while ($arr[$j] <= $arr[$i - 1]) //>= for prev
@alok-sin
alok-sin / shiro
Created April 9, 2015 07:38
finding longest var declared in PHP or js
#php
egrep -oshRI '(\$[a-zA-Z_0-9]+)' ./ | awk -F ':' '{ print length $1}' | sort -gr | head -n 1
#js
egrep -shIRo --include \*.js '(?:[\n\( ])([a-zA-Z_0-9]+) *=' ./ | awk '{ print length, $1}' | sort -gr | head -n 1`