Skip to content

Instantly share code, notes, and snippets.

View bjarneo's full-sized avatar
🏠
Working from home

bjarneo bjarneo

🏠
Working from home
View GitHub Profile
$now = time();
$cache_timer = get_option('frontpage_categories_box_cachetime', $now);
if ($cache_timer > $now) {
$content = get_option('frontpage_cateogires_box_content');
if (empty($content)) {
ob_start();
include 'views/frontpage_categories_box.php';
$content = ob_get_clean();
update_option('frontpage_cateogires_box_content', $content);
update_option('frontpage_categories_box_cachetime', (time() + (60 * 60)));
@bjarneo
bjarneo / isTransformSupported
Created January 21, 2015 11:38
JavaScript - css3 transform support
var isTransformSupported = function() {
var prefixes = [
'transform',
'WebkitTransform',
'MozTransform',
'OTransform',
'msTransform'
], len = prefixes.length;
while (len--) {
@bjarneo
bjarneo / strreplace
Created February 3, 2015 12:24
Recursive string replacement
find . -iname '*php' | xargs grep 'mysql' -sl | while read x; do echo $x; sed -i 's/mysql/mysqli/' $x; done
@bjarneo
bjarneo / Pushbullet
Last active August 29, 2015 14:15
Pushbullet - send basic note
#!/usr/bin/env python
import urllib
import urllib2
import base64
import json
config = {
'api': 'https://api.pushbullet.com/v2/pushes',
'token': 'your_token'
@bjarneo
bjarneo / pushover
Last active August 29, 2015 14:15
Pushover - send basic msg
#!/usr/bin/env python
import urllib
import urllib2
import json
config = {
'api': 'https://api.pushover.net/1/messages.json',
'user': 'user_key',
'token': 'your_token'
@bjarneo
bjarneo / vim_configs
Last active August 29, 2015 14:17
VIM
" Vim Cheat sheet
" http://vim.rtorr.com/
" If ctrl + s freezes your vim, use this config in .bashrc to disable sending xoff
" stty -ixon
" This command will remove trailing whitespace on save
autocmd BufWritePre *.* :%s/\s\+$//e
" Set line numbers
@bjarneo
bjarneo / ab
Last active August 29, 2015 14:18
a/b javascript
var r = 0,
len = 1000000,
a = 0, b = 0;
while (len--) {
r = Math.floor(Math.random() * 2) + 1;
if (r === 1) {
a++;
} else {
@bjarneo
bjarneo / npm
Created May 21, 2015 18:28
run npm without sudo
sudo chown -R $(whoami) ~/.npm
@bjarneo
bjarneo / Resources
Created May 27, 2015 06:03
Resources
Model + View
http://stackoverflow.com/a/5864000
@bjarneo
bjarneo / test_async
Created June 30, 2015 10:21
Test async. Use this to block.
var stop = new Date().getTime();
while(new Date().getTime() < stop + 10000);