Skip to content

Instantly share code, notes, and snippets.

View rendfall's full-sized avatar
💭
Coffee is a drink, not a language! ☕️

rendfall rendfall

💭
Coffee is a drink, not a language! ☕️
View GitHub Profile
@rendfall
rendfall / get-remote-filesize.php
Created October 16, 2016 20:51
Get remote filesize
function getRemoteFilesize($url, $formatSize = true, $useHead = true) {
if (false !== $useHead) {
stream_context_set_default(array('http' => array('method' => 'HEAD')));
}
$head = array_change_key_case(get_headers($url, 1));
// content-length of download (in bytes), read from Content-Length: field
$clen = isset($head['content-length']) ? $head['content-length'] : 0;
// cannot retrieve file size, return "-1"
@rendfall
rendfall / proxy-observer.js
Created September 14, 2016 20:22
Use proxy like observer
let object = {};
object = new Proxy(object, {
set: (o, prop, value) => {
console.warn(`${prop} is set to ${value}`);
o[prop] = value;
},
get: (o, prop) => {
console.warn(`${prop} is read`);
return o[prop];
@rendfall
rendfall / antispam.js
Created September 8, 2016 19:09
Anti-Spam Email Encoder
// Example for gmail accounts only >> rot13(tznvy.pbz)
function getEmail(u) {
var c = ':otliam'.split('').reverse().join('');
var a = String.fromCharCode('0'+8*8);
var h = 'tznvy.pbz'.replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);});
return c+u+a+h;
}
@rendfall
rendfall / tilemap-array.js
Last active August 13, 2016 16:19
Simple implementation of tilemap rendering from array
// <canvas id="main"></canvas>
function init() {
// The two dimensional map array as it sounds is basically your world and what will be drawn.
// Each number can represet a different graphic or possible enviroment interaction.
// In this tutorial case we only have two possible tiles, zero which is blank and one which is filled.
var map = [
[1,0,1,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1],
[1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
git tag -l | xargs git tag -d
git fetch
@rendfall
rendfall / git-undo-custom-commit.sh
Created May 24, 2016 10:10
[GIT] Undo custom bad commit
git checkout <bad-commit>
# ... make your changes ...
git commit --amend -v
git rebase --onto HEAD <bad-commit> <checked-out-branch>
@rendfall
rendfall / Object.watch
Created November 5, 2015 09:06
Object.watch by Eli Grey’s
// object.watch by Eli Grey: https://gist.github.com/eligrey/175649
if (!Object.prototype.watch)
{
Object.prototype.watch = function (prop, handler)
{
var val = this[prop],
getter = function ()
{
return val;
},
@rendfall
rendfall / bash-shell-autorun
Created September 30, 2015 20:48
Bash shell on startup
sudo chsh -s /bin/bash username
@rendfall
rendfall / aliases
Last active November 23, 2016 12:35
Cmder - Aliases
.. = cd ..
pro = cd /projects
ll=ls -Xal --color
ip = ipconfig | grep "IPv4"
build = npm run build
bb = npm run build
n = npm $*
@rendfall
rendfall / autoclick.js
Created September 9, 2015 09:29
[YouTube] Create playlist using `watch later` button
// Warning: if you want add 300+ files your chrome will probably crash.
var a=document.querySelectorAll('.yt-uix-button');for(var i=0,l=a.length;i<l;i++){a[i].click()};