Skip to content

Instantly share code, notes, and snippets.

Avatar

Yan Sern yansern

View GitHub Profile
@yansern
yansern / SqlServerGrammar.php
Created Feb 15, 2018
SqlServerGrammar with OFFSET..FETCH support
View SqlServerGrammar.php
<?php
namespace Illuminate\Database\Query\Grammars;
use Illuminate\Support\Arr;
use Illuminate\Database\Query\Builder;
class SqlServerGrammar extends Grammar
{
/**
@yansern
yansern / gulpfile.js
Created Dec 4, 2016 — forked from Falconerd/gulpfile.js
Gulp + Watchify + Babelify + BrowserSync
View gulpfile.js
/**
* This gulpfile will copy static libraries and a index.html file as well as
* merge, babelify and uglify the rest of the javascript project.
*
* TODO:
* - Separate media, libs and src with different watchers.
* - Media and libs should only be copied to dist if they are different sizes.
*
* The expected project is to be laid out as such:
*
View gist:26f3873d997f34537172
var wordList = [
"a",
"aardvark",
"aback",
"abacus",
"abaft",
"abalone",
"abandon",
"abandoned",
"abase",
View normalise-path.php
<?php
/**
* Normalise a file path string so that it can be checked safely.
*
* Attempt to avoid invalid encoding bugs by transcoding the path. Then
* remove any unnecessary path components including '.', '..' and ''.
*
* @param $path string
* The path to normalise.
* @param $encoding string
@yansern
yansern / gist:86eb5a02454217b3cef9
Created Aug 21, 2014
McDonalds WiFi KeepAlive script (not working)
View gist:86eb5a02454217b3cef9
USER_MAC=$(ifconfig en1 | grep ether | sed 's/.*ether //g' | awk -F: '{printf("%02s:%02s:%02s:%02s:%02s:%02s",$1,$2,$3,$4,$5,$6)}')
OUTLET_MAC=$(arp $(route get default | grep gateway | sed 's/ gateway: //g') | sed 's/.* at //g' | sed 's/ on.*//g' | awk -F: '{printf("%02s-%02s-%02s-%02s-%02s-%02s",$1,$2,$3,$4,$5,$6)}')
POST_DATA="'checky=1&user_mac=$USER_MAC&outlet_mac=$OUTLET_MAC'"
PHPSESSID=$(curl -I -G --max-redirs 0 http://login.d-synergy.com/mcdonalds-new/index.php --data $POST_DATA | grep PHPSESSID | sed 's/.*PHPSESSID=//g' | sed 's/.*PHPSESSID=//g' | sed 's/\;.*//g')
COOKIE="'Cookie: PHPSESSID=$PHPSESSID'"
POST_DATA="'checky=1&user_mac=$USER_MAC&outlet_mac=$OUTLET_MAC'"
echo $COOKIE
echo $POST_DATA
curl 'http://login.d-synergy.com/mcdonalds-new/check.php' -H $COOKIE -H 'Origin: http://login.d-synergy.com' -H 'Content-Type: application/x-www-form-urlencoded' --data $POST_DATA
@yansern
yansern / gist:4ff8478d179689960f15
Created Jun 6, 2014
Selector Function Extension
View gist:4ff8478d179689960f15
$.Controller("Comment",
{
defaultOptions: {
"{comment}": "[data-comment]"
}
},
function(self) { return {
comment: {
remove: function(id) {
@yansern
yansern / gist:2ea7077236a1245c397a
Last active Aug 29, 2015
Image Fill Strategy (XOR Table)
View gist:2ea7077236a1245c397a

Image Fill Strategy

AND Tall Viewport (<1) Square Viewport (=1) Wide Viewport (>1)
Tall Image (<1) fit-height fit-width fit-width
Square Image (=1) fit-height fit-width/fit-height fit-width
Wide Image (>1) fit-height fit-height fit-width
You can’t perform that action at this time.