Skip to content

Instantly share code, notes, and snippets.

View thrashr888's full-sized avatar
🐮
moo

Paul Thrasher thrashr888

🐮
moo
View GitHub Profile
@thrashr888
thrashr888 / gist:3880933
Created October 12, 2012 19:15
the most amazing javascript code i've ever written
<script>
var docwritebuffer = "";
document.wrong = document.write;
document.write = function(html){
docwritebuffer = html;
}
</script>
<script type="text/javascript" src="http://myforum.disqus.com/popular_threads_widget.js?num_items=5"></script>
<script>
document.write = document.wrong;
<?php
// Usage:
// $master=new WebSocket("localhost",12345);
// $master->callback = function($self, $user, $msg){
// $self->send($user->socket,$msg);
// };
require "CommandsAppBase.class.php";
require "WsRequest.class.php";
// respond to key events
Game.Player.prototype.keyUp = function (e) {
delete this._keysPressed[e.key];
};
// respond to key events
Game.Player.prototype.keyDown = function (e) {
this._keysPressed[e.key] = true;
@thrashr888
thrashr888 / recursive-fetch.js
Last active March 24, 2018 03:32
recursive fetch for wordpress API
let lastPage = 25;
let self = this;
function getPage(thisPage) {
console.log('Loading page', thisPage);
fetch(self.state.url + '&page=' + thisPage)
.then(response => {
if (response.headers.has('X-WP-TotalPages')) {
lastPage = response.headers.get('X-WP-TotalPages');
}
return response.json();
@thrashr888
thrashr888 / cache.php
Last active March 24, 2018 03:32
php file cache example
<?php
function get_cache($key) {
$cacheFolder = '/tmp/wp-site/';
$cacheFile = $cacheFolder+$key
if(file_exists($cacheFile) {
$contents = file_read($cacheFile);
return json_decode($contents);
} else {
return false;
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "O", function()
hs.notify.new({title="Hammerspoon", informativeText="Hello World"}):send()
end)
-- Move window up
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "W", function()
local win = hs.window.focusedWindow()
local f = win:frame()
function cpu_load() {
ps -A -o %cpu | awk '{s+=$1} END {print s "%"}'
}
function battery_load() {
pmset -g batt | grep -o '[0-9]*%' | tr -d %
}
export PS1='`if [ $? = 0 ]; then echo "\[\033[01;32m\]✔"; else echo "\[\033[01;31m\]✘"; fi` \[\033[01;37m\]\u\[\033[01;36m\] \[\033[01;33m\]\t \[\033[01;37m\]($(cpu_load)) [\[\033[01;33m\]$(battery_load)⚡\[\033[01;37m\]] \[\033[01;36m\]\W\[\033[35m\]$(__git_ps1 " %s") \[\033[01;37m\]⚡\[\033[00m\] '
{
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/.DS_Store": true,
"**/tmp": true,
"**/yarn_cache": true
// "**/env": true
},
# install dependencies
sudo apt-get install libcurl4-openssl-dev libncurses5-dev pkg-config automake yasm
# clone cpuminer
git clone https://github.com/pooler/cpuminer.git
# compile
cd cpuminer
./autogen.sh
./configure CFLAGS="-O3"
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://gist.github.com/thrashr888/6047603/raw/6584ab9c5d500613303c852d79d619690b835305/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"