Skip to content

Instantly share code, notes, and snippets.

View ozh's full-sized avatar
🍷
More wine, please.

྅༻ Ǭɀħ ༄༆ཉ ozh

🍷
More wine, please.
View GitHub Profile

rage-quit support for bash

HOW TO INSTALL

Put flip somewhere in your $PATH and chmod a+x it.

Copy fuck into ~/.bashrc.

@ozh
ozh / gist:4032822
Created November 7, 2012 16:49 — forked from markjaquith/gist:2628225
Script to sync WordPress SVN to GitHub
#!/bin/bash
# cd into the directory
cd ~/gitsync/github-wordpress-sync/;
# Make sure we are not already running
if [ -f .sync-running ];then
if test ! `find ".sync-running" -mmin +10`;then
# Currently running, but not stuck
exit 1;
fi
fi;
@ozh
ozh / script-template.sh
Created May 19, 2021 19:43 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@ozh
ozh / git-clone-into-not-empty-dir.md
Last active September 7, 2021 13:56 — forked from davisford/gist:5039064
git clone into non-empty directory

You have a folder with files

$ mkdir -p ~/foo && cd ~/foo
$ touch NEWFILE

You cannot git clone into it because the directory is not empty. To do so:

@ozh
ozh / HashCipher.php
Last active November 26, 2021 02:11 — forked from ircmaxell/HashCipher.php
<?php
class HashCipher {
protected $hash = 'sha512';
protected $hashLen = 64;
protected $rounds = 16;
public function __construct($hash, $rounds = 16) {
$this->hash = $hash;
// run a test hash, to get the proper hash length
<?php
/**
* This function computes a hash of an integer. This can be used to not expose values to a customer, such as
* not giving them the id value for passing them to URLs. This algorithm is a bidirectional encryption (Feistel cipher) that maps
* the integer space onto itself.
*
* @link http://wiki.postgresql.org/wiki/Pseudo_encrypt Algorithm used
* @link http://en.wikipedia.org/wiki/Feistel_cipher Wikipedia page about Feistel ciphers
* @param int $value
@ozh
ozh / ascii-wp-logo.txt
Created January 8, 2013 22:27 — forked from markjaquith/gist:4487609
WordPress logo - ascii style
<!--
`-/+osssssssssssso+/-`
./oys+:.` `.:+syo/.
.+ys:. .:/osyyhhhhyyso/:. ./sy+.
/ys: -+ydmmmmmmmmmmmmmmmmmmdy+- :sy/
/h+` -odmmmmmmmmmmmmmmmmmmmmmmmmmmdo- `+h/
:ho` /hmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmds/ `oh:
`sy. /hmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmd+ .ys`
.ho `sdddhhhyhmmmdyyhhhdddddhhhyydmmmmy oh.
@ozh
ozh / disable-plugins-when-doing-local-dev.php
Created November 7, 2012 16:44 — forked from johnpbloch/disable-plugins-when-doing-local-dev.php
Disables specified WordPress plugins when doing local development
<?php
/*
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
@ozh
ozh / gist:3928158
Created October 21, 2012 19:17
YOURLS to TweetButton
javascript:(function(){var d=document,s=d.createElement('script');window.yourls_callback=function(r){if(r.short_url){javascript:window.open('https://twitter.com/intent/tweet?text='+encodeURIComponent(' '+r.short_url+' '+d.title.replace(/^[ ]+|[ ]+$/g, '')),'Tweet','width=400,height=260');}else{alert('An error occured: '+r.message);}};s.src='http://u.vanu.jp/admin/index.php?u='+encodeURIComponent(d.location.href)+'&jsonp=yourls';void(d.body.appendChild(s));})();
@ozh
ozh / example.php
Last active July 26, 2022 11:55 — forked from sobi3ch/gist:5451004
PHP Array pluck function
<?php
$foods = array(
array(
'id' => 4,
'name' => 'Banana',
'color' => 'Yellow',
),
array(
'id' => '5',
'name' => 'Apple',