Skip to content

Instantly share code, notes, and snippets.

View yansern's full-sized avatar

Yan Sern yansern

View GitHub Profile
@yansern
yansern / SqlServerGrammar.php
Created February 15, 2018 14:55
SqlServerGrammar with OFFSET..FETCH support
<?php
namespace Illuminate\Database\Query\Grammars;
use Illuminate\Support\Arr;
use Illuminate\Database\Query\Builder;
class SqlServerGrammar extends Grammar
{
/**
@yansern
yansern / gulpfile.js
Created December 4, 2016 21:37 — forked from Falconerd/gulpfile.js
Gulp + Watchify + Babelify + BrowserSync
/**
* 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:
*
var wordList = [
"a",
"aardvark",
"aback",
"abacus",
"abaft",
"abalone",
"abandon",
"abandoned",
"abase",
@yansern
yansern / gist:86eb5a02454217b3cef9
Created August 21, 2014 02:18
McDonalds WiFi KeepAlive script (not working)
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 June 6, 2014 10:22
Selector Function Extension
$.Controller("Comment",
{
defaultOptions: {
"{comment}": "[data-comment]"
}
},
function(self) { return {
comment: {
remove: function(id) {
<?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:2ea7077236a1245c397a
Last active August 29, 2015 14:01
Image Fill Strategy (XOR Table)

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