Skip to content

Instantly share code, notes, and snippets.

@undernewmanagement
undernewmanagement / slugify.sql
Created April 10, 2012 03:56 — forked from chanmix51/slugify.sql
slugification in plpgsql
CREATE OR REPLACE FUNCTION slugify(title VARCHAR) RETURNS varchar AS $$
BEGIN
RETURN trim(both '-' from regexp_replace(lower(transliterate(title)), '[^a-z0-9]+', '-', 'g'));
END;
$$ LANGUAGE plpgsql;
@undernewmanagement
undernewmanagement / transliterate.sql
Created April 10, 2012 04:46 — forked from chanmix51/transliterate.sql
transliteration in plpgsql
CREATE OR REPLACE FUNCTION transliterate(my_text VARCHAR) RETURNS varchar AS $$
DECLARE
text_out VARCHAR DEFAULT '';
BEGIN
text_out := my_text;
text_out := translate(text_out, 'àâäåáăąãā', 'aaaaaaaaa');
text_out := replace(text_out, 'æ', 'ae');
text_out := translate(text_out, 'çċćčĉ', 'ccccc');
text_out := translate(text_out, 'éèėëêēĕ', 'eeeeeee');
text_out := translate(text_out, 'îïìíī', 'iiiii');
// You create your bookmarklet by instantiating
// a new Bookmarklet function, then pass in the options like so.
// This example checks to see if the var is already defined, and makes
// sure not to overwrite it. This could happen if the user clicks on
// the bookmarklet more than once.
MyBookmarklet = MyBookmarklet || (MyBookmarklet = new Bookmarklet({
// debug: true, // use debug to bust the cache on your resources
css: ['/my/style.css'],
js: [],
@undernewmanagement
undernewmanagement / router.js
Created September 8, 2014 20:48
React-router
/** @jsx React.DOM */
var React = require('react'),
Router = require('react-router'),
Route = Router.Route,
Routes = Router.Routes,
Link = Router.Link,
App = require('./components/App.jsx'),
Dashboard = require('./components/Dashboard.jsx');
@undernewmanagement
undernewmanagement / google_autocomplete_table.js
Created April 22, 2015 22:53
Appcelerator titanium google places autocomplete
//AUTOCOMPLETE TABLE
var table_data = [];
var last_search = null;
var timers = [];
// NOTE: iOS and Android keys will be different!
var IOS_API_KEY = 'xxx__APIKEY___xxx';
var ANDROID_API_KEY = '';
#!/bin/bash
if swapon -s | grep -q /mnt/swapfile
then
echo "Swapfile already mounted"
else
if [ -e /mnt/swapfile ]
then
echo "Mounting swapfile"
swapon /mnt/swapfile
@undernewmanagement
undernewmanagement / simply reply to recruiter spam.txt
Last active November 2, 2015 10:27
My simple reply to unsolicited recruiter spam
Originally appeared on my medium page here: https://medium.com/@unmgmt
Thanks for reaching out.
I charge $____ USD per day plus travel and expenses for my services. Clients pay on retainer in increments of __ days minimum.
Any referrals I make come with a __% finders fee for the first ___ hours billed, or ___% of the gross yearly salary.
I am currently on assignment in _____, _____ until _____.
@undernewmanagement
undernewmanagement / gist:e5164afbe0ee240a48dc
Created December 28, 2015 12:41
Get IP address of a VM using azure cli
azure vm show <RG_GROUP> <VM_NAME> |grep "Public IP address" | awk -F ":" '{print $3}'
@undernewmanagement
undernewmanagement / transmission-ssl
Created February 10, 2016 12:50 — forked from Belphemur/transmission-ssl
Configuration to use nginx as reverse proxy for Transmission BT with SSL protected with auth
upstream transmission {
server 127.0.0.1:9091; #Transmission
}
server {
listen 443 ssl spdy;
server_name example.com;
auth_basic "Server Restricted";
auth_basic_user_file /var/www/myWebSite/web/.htpasswd;
# Path to the root of your installation
@undernewmanagement
undernewmanagement / gist:643ee5f3a5366c430c00
Created February 14, 2016 23:41
Config for transmission behind nginx
# all credit goes to: https://www.dgsec.net/transmission-web-over-https-with-nginx/
server {
listen 443 ssl;
listen [::]:443 ssl ;
server_name torrent.YOURDOMAIN.NET;
ssl_certificate ssl/YOURCERT.crt;
ssl_certificate_key ssl/YOURCERT.pem;