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
@johnpbloch
johnpbloch / README.md
Last active December 21, 2015 06:28
Install Boris, PHPUnit, and Mockery globally with Composer
@msegu
msegu / toURI.php
Last active May 26, 2020 16:34
URL/URI full encoding
<?php
/*
Need to encode given (finished) path and query?, for example
'http://example.org:port/path1/path2/data?key1=value1&argument#fragment' (1)
or 'scheme://user:password@example.com:port/path1/path2/data?key1=value1&key2=value2#fragment' (2)
e.g. this (2) should be encoded:
'scheme://'.rawurlencode('user').':'.rawurlencode('password').'@example.com:port/'
.rawurlencode('path1').'/'.rawurlencode('path2').'/'.rawurlencode('data')
.'?'.htmlentities(urlencode('key1').'='.urlencode('value1').'&'.urlencode('key2').'='.urlencode('value2'))
@Ozhcar
Ozhcar / dir_file_renamer.py
Last active April 5, 2021 18:03
For my dad
from PIL import Image, ImageFont, ImageDraw
import glob
import os
import re
import time
""""""
dir_to_watch_name = './to_watch'
watch_every = 10
@vielhuber
vielhuber / App.php
Last active June 14, 2021 06:50
properly test header redirect in phpunit #php
<?php
// src/App.php
namespace Example;
class App
{
public function redirect($url)
{
header('Location: ' . $url, true, 302);
die();
@kylefrost
kylefrost / HOWTO.md
Last active July 31, 2021 19:24
How-To: Tweet All Commit Messages

Creating the post-commit file

Note: If you want to use your personal Twitter account to post commits, go to Step 2

  1. Create a new Twitter account for your commit messages. Example
  2. Go to http://dev.twitter.com and Sign In with your Twitter account you are posting commit messages to.
  3. Hover over your username in the top-right corner after signing in and select "My Applications"
  4. Create a new application
  5. The name, description, and site can all be whatever you want, but leave Callback URL empty
  6. Under "Application Settings" click "modify app permissions" next to "Access level"
@grantslatton
grantslatton / hngen.py
Last active September 27, 2021 11:07
A program that uses Markov chains to generate probabilistic Hacker News titles.
import urllib2
import re
import sys
from collections import defaultdict
from random import random
"""
PLEASE DO NOT RUN THIS QUOTED CODE FOR THE SAKE OF daemonology's SERVER, IT IS
NOT MY SERVER AND I FEEL BAD FOR ABUSING IT. JUST GET THE RESULTS OF THE
CRAWL HERE: http://pastebin.com/raw.php?i=nqpsnTtW AND SAVE THEM TO "archive.txt"
@ozh
ozh / userDefineLang.xml
Created February 14, 2013 13:42
Notepad++ : userDefineLang.xml for Markdown
<NotepadPlus>
<UserLang name="Markdown" ext="mkdn mkd md" udlVersion="2.0">
<Settings>
<Global caseIgnored="yes" allowFoldOfComments="no" forceLineCommentsAtBOL="no" foldCompact="no" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments" id="0">00# 00## 00### 00#### 00##### 01 02 03&lt;!-- 04--&gt;</Keywords>
<Keywords name="Numbers, additional" id="1"></Keywords>
<Keywords name="Numbers, prefixes" id="2"></Keywords>
@davisford
davisford / gist:5039064
Last active February 9, 2022 13:39
git clone into non-empty directory

Let's say you start a project locally, and do some editing.

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

Now you decide you want to create a new github repo and track it, but the directory is non-empty so git won't let you clone into it. You can fix this, thusly:

@tivnet
tivnet / apigen-hooks.php
Created November 2, 2016 17:58
Generate list of hooks (for WPGlobus)
<?php
/**
* File: apigen-hooks.php
*
* NOTE: this code is used internally in WPGlobus project.
* It's a W.I.P. - please use it, but do not forget to adapt for your project.
*
* @package WPGlobus\APIGen
* @author Gregory Karpinsky (@tivnet)
*/
@hashworks
hashworks / kutt.sh
Created November 6, 2020 17:25
BASH function for kutt.it URL shortener services
KUTT_HOST="https://kutt.it"
KUTT_API_KEY="API_KEY"
kutt() {
if [[ "$1" == "delete" ]] && [[ -n "$2" ]]; then
curl -s -H "X-API-KEY: $KUTT_API_KEY" \
-X DELETE \
"$KUTT_HOST/api/v2/links/$2" | jq
elif [[ -z "$1" ]]; then
curl -s -H "X-API-KEY: $KUTT_API_KEY" \
"$KUTT_HOST/api/v2/links" | jq