Skip to content

Instantly share code, notes, and snippets.

@joelambert
joelambert / README
Created June 1, 2011 11:03
Drop in replacements for setTimeout()/setInterval() that makes use of requestAnimationFrame() where possible for better performance
Drop in replace functions for setTimeout() & setInterval() that
make use of requestAnimationFrame() for performance where available
http://www.joelambert.co.uk
Copyright 2011, Joe Lambert.
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php
@potfur
potfur / $.js
Last active February 15, 2023 14:49
window.S = function(s) {
return document[{
'#': 'getElementById',
'.': 'getElementsByClassName',
'@': 'getElementsByName',
'=': 'getElementsByTagName'}[s[0]]
|| 'querySelectorAll'](s.slice(1))
};
// [S('#header'), S('.container'), S('?div')]
@levelsio
levelsio / btc-eth-dca-buy.php
Last active January 6, 2023 22:04
This script runs daily and "Dollar Cost Average"-buys $40 BTC and $10 ETH per day
<?
//
// [ BUY BTC & ETH DAILY ON BITSTAMP ]
// by @levelsio
//
// 2017-08-23
//
// 1) buy $40/day BTC
// 2) buy $10/day ETH
//
@johnkary
johnkary / xray.php
Last active November 18, 2022 23:58
Exposing protected and private object methods using \Closure::bindTo(). Code below requires PHP 5.6+ due to argument unpacking (...$args). Could probably be written for PHP 5.4+ but didn't want to reinvent argument unpacking, else could also just use the Reflection implementation.
<?php
class User {
private $firstname;
private $lastname;
public function __construct($f, $l) {
$this->firstname = $f;
$this->lastname = $l;
}
@drakakisgeo
drakakisgeo / gist:48dcab1539612c82449b9757940ac7ee
Last active August 29, 2022 02:41
Print Access Token from Laravel Passport
<?php
namespace App\Traits;
use App\User;
use DateTime;
use GuzzleHttp\Psr7\Response;
use Illuminate\Events\Dispatcher;
use Laravel\Passport\Bridge\AccessToken;
use Laravel\Passport\Bridge\AccessTokenRepository;
@jahilldev
jahilldev / tiny-debounce.js
Last active July 28, 2022 17:05
Tiny JavaScript debounce function
function debounce(callback, frequency = 250, timer = null) {
return (...args) => (
clearTimeout(timer), (timer = setTimeout(callback, frequency, ...args))
);
}
@doersino
doersino / backup_tumblr.sh
Last active January 15, 2022 23:32
Simple way of backing up one or multiple Tumblr blogs to date-prefixed folders; downloads and removes required software (except Python) automatically. http://neondust.tumblr.com/post/97723922505/simple-tumblr-backup-script-for-mac-os-x-and-linux
#!/bin/bash
# http://neondust.tumblr.com/post/97723922505/simple-tumblr-backup-script-for-mac-os-x-and-linux
# https://gist.github.com/doersino/7e3e5db591e42bf543e1
# BLOGS is a space-separated list of the blogs you want to backup. You can omit
# the ".tumblr.com" part if you want.
BLOGS="neondust.tumblr.com aufgeloest.tumblr.com hejlisten.tumblr.com"
# OUT is the directory where the backups will be stored. For each blog, a date-
# prefixed subdirectory will be created here.
@renatomefi
renatomefi / README.md
Last active December 13, 2021 12:15
Milhog start script for Ubuntu 14.04

This is a simple way to install mailhog, might not be the best solution for everyone, you can look for repositories, still have to register the binary in the PATH, among other things, this is a manual simple install.

Binary download

Download mailhog from the releases page on github: https://github.com/mailhog/MailHog/releases Save the binary at /opt/mailhog/mailhog Give it executable permission chmod +x /opt/mailhog/mailhog

Init script

Download the gist: https://gist.github.com/renatomefi/d133fea9cb5a7b00f91edb24b83d9a31#file-init-d-mailhog-sh Put it at /etc/init.d/mailhog

@MawKKe
MawKKe / split_ffmpeg.py
Last active August 7, 2021 21:50
MOVED TO: https://github.com/MawKKe/audiobook-split-ffmpeg | Split audio file with ffmpeg based on chapter metadata
#!/usr/bin/env python3
import sys
import os
import re
import subprocess as sub
import argparse
import tempfile
import json
from concurrent.futures import ThreadPoolExecutor, as_completed
@techslides
techslides / wp-ajax-upload.php
Last active November 26, 2020 14:15
Upload to WordPress with Ajax and FormData
<input type="file" name="file" id="file">
<input type="submit" id="submit" name="Upload" onclick="upload();return false;">
<script type="text/javascript">
function upload(){
var formData = new FormData();
formData.append("action", "upload-attachment");
var fileInputElement = document.getElementById("file");
formData.append("async-upload", fileInputElement.files[0]);