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
@ozh
ozh / gist:5453373
Created April 24, 2013 16:13
Mirror a Google Code project on Github after every commit
@ozh
ozh / gist:5453664
Created April 24, 2013 16:53
Nightly build from an SVN repo
#!/bin/bash
# Simple bash script to generate YOURLS nightly builds
# Export in a year-month-day directory
PWD="/home/ozh/yourls.org/nightly-builds"
BUILD=$(date +%Y-%m-%d)
svn -q export http://yourls.googlecode.com/svn/trunk/ $PWD/$BUILD
# Make package and remove dir
cd $PWD
@ozh
ozh / gist:5495656
Last active December 16, 2015 20:50
YOURLS bookmarklets - unformatted for readability
// Share on Facebook
var d = document,
enc = encodeURIComponent,
share = 'facebook',
f = 'http://sho.rt/admin/index.php',
l=d.location.href,
ups=l.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ )[0];
var ur=l.split(new RegExp(ups))[1];
var ups=ups.split(/\:/);
<?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 / gist:5518761
Last active December 17, 2015 00:10
List of YOURLS "phone home" stuff

List of stuff the "phone home" YOURLS function will report:

Internal: what to store in yourls_options

  • time of last check. Define minimum delay between 2 requests (24 hours if success, 1 hour if failure?)
  • number of previous consecutive failed attempts to join api.yourls.org (monitor performance of the system)
  • return of previous successful requrest to api.yourls.org (nag about new version even if host unreachable)

Server & YOURLS config

@ozh
ozh / gist:5607258
Last active December 17, 2015 12:09
Firefox Responsive mode: custom resolutions

How to add custom resolutions in Firefox Responsive Mode

  1. open about:config
  2. look for devtools.responsiveUI.presets
  3. paste the following string: `[{"key":"2560x1440","width":2560,"height":1440},{"key":"1920x1200","width":1920,"height":1200},{"key":"1680x1050","width":1680,"height":1050},{"key":"1600x1200","width":1600,"height":1200},{"key":"1600x900","width":1600,"height":900},{"key":"1440x900","width":1440,"height":900},{"key":"1366x768","width":1366,"height":768},{"key":"1280x1024","width":1280,"height":1024},{"key":"1280x800","width":1280,"height":800},{"key":"1280x768","width":1280,"height":768},{"key":"1152x864","width":1152,"height":864},{"key":"1024x768","width":1024,"height":768},{"key":"800x600","width":800,"height":600},{"key":"800x1280","width":800,"height":1280},{"key":"768x1024","width":768,"height":1024},{"key":"640x960","width":640,"height":960},{"key":"360x640","width":360,"height":640},{"key":"320x480","width":320,"height":480},{"key":"320x396","width":320,"height":396},{"key":"2
@ozh
ozh / gist:5774354
Created June 13, 2013 14:56
javascript check if flash supported
function is_flash_enabled() {
var hasFlash = false;
try {
var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
if( fo ) hasFlash = true;
} catch(e) {
if( navigator.mimeTypes ["application/x-shockwave-flash"] != undefined )
hasFlash = true;
}
return hasFlash;
@ozh
ozh / gist:5822331
Created June 20, 2013 12:34
Get current path in PHP
<?php
function request_path() {
$request_uri = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
$script_name = explode('/', trim($_SERVER['SCRIPT_NAME'], '/'));
$parts = array_diff_assoc($request_uri, $script_name);
if (empty($parts)) {
return '/';
}
$path = implode('/', $parts);
@ozh
ozh / gist:6192069
Created August 9, 2013 08:38
Long live the BLINK tag
/* That's right bitches */
@keyframes blink {
0% { opacity:1; } 75% { opacity:1; } 76% { opacity:0; } 100% { opacity:0; }}
@-webkit-keyframes blink {
0% { opacity:1; } 75% { opacity:1; } 76% { opacity:0; } 100% { opacity:0; }}
@-moz-keyframes blink {
0% { opacity:1; } 75% { opacity:1; } 76% { opacity:0; } 100% { opacity:0; }}
@-ms-keyframes blink {
0% { opacity:1; } 75% { opacity:1; } 76% { opacity:0; } 100% { opacity:0; }}
@ozh
ozh / gist:6306765
Last active December 21, 2015 12:38
BaseXX encode / decode. Consider replacing YOURLS functions with this to drop bcmath dependency
<?php
class BaseEncDec {
public $alphabet;
public $base;
public function __construct( $alphabet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ) {
$this->alphabet = $alphabet;
$this->base = strlen( $alphabet );
}