Skip to content

Instantly share code, notes, and snippets.

View smowtion's full-sized avatar

Smowtion smowtion

View GitHub Profile
#!/bin/bash
#Force file syncronization and lock writes
mongo admin --eval "printjson(db.fsyncLock())"
MONGODUMP_PATH="/usr/bin/mongodump"
MONGO_HOST="prod.example.com"
MONGO_PORT="27017"
MONGO_DATABASE="dbname"
@smowtion
smowtion / DBConnection.php
Created September 14, 2016 17:51 — forked from tkdave/DBConnection.php
Memcache-backed MySQL Database connection class.
<?php
/**
* Lazy Database connection class - API version
*
* The database is not actually opened until we execute a query
*
* @author David Knape
*/
class DBConnection
@smowtion
smowtion / currency_symbols.php
Created February 27, 2017 17:15 — forked from gibbs/currency_symbols.php
An array of currency symbols as HTML entities
<?php
$currency_symbols = array(
'AED' => '&#1583;.&#1573;', // ?
'AFN' => '&#65;&#102;',
'ALL' => '&#76;&#101;&#107;',
'AMD' => '',
'ANG' => '&#402;',
'AOA' => '&#75;&#122;', // ?
'ARS' => '&#36;',
'AUD' => '&#36;',
@smowtion
smowtion / nginx.conf
Created March 2, 2017 17:14 — forked from un33k/nginx.conf
Enable Nginx to send Content-Dispositions on specific files
server {
listen *:80;
server_name www.example.com;
rewrite ^(.*) http://example.com $1 permanent;
}
server {
listen *:80;
server_name example.com;
@smowtion
smowtion / secure_link.php
Created March 27, 2017 16:41 — forked from bftanase/secure_link.php
generate URL for nginx secure_link
@smowtion
smowtion / global-variables-are-bad.js
Created May 16, 2017 16:35 — forked from hallettj/global-variables-are-bad.js
How and why to avoid global variables in JavaScript
// It is important to declare your variables.
(function() {
var foo = 'Hello, world!';
print(foo); //=> Hello, world!
})();
// Because if you don't, the become global variables.
(function() {
@smowtion
smowtion / mem.sh
Created May 28, 2017 09:13 — forked from fwolf/mem.sh
Monitor memory usage in VPS
#! /bin/bash
# https://gist.github.com/fwolf/5856230
#ps aux --width 80 | sort -nrk +6 | head -n 15
# bsdtime is shorter than cputime, hh:mm:ss vs MMM:SS
ps -eo 'user,pid,%cpu,%mem,rss,vsz,stime,bsdtime,s,cmd' --sort '-rss,-vsz' --width 80 | head -n 16
echo
@smowtion
smowtion / ResizeImage.php
Created March 26, 2018 13:57 — forked from egulhan/ResizeImage.php
Resize Image Class With PHP
<?php
// @source: http://www.paulund.co.uk/resize-image-class-php
/**
* Resize image class will allow you to resize an image
*
* Can resize to exact size
* Max width size while keep aspect ratio
* Max height size while keep aspect ratio
* Automatic while keep aspect ratio
@smowtion
smowtion / svg2icns
Created May 20, 2018 03:47 — forked from zlbruce/svg2icns
covert svg to icns (with imagemagick)
#!/bin/bash
echo "*** SVG 2 ICNS ***"
if [ $# -ne 1 ]; then
echo "Usage: svg2icns filename.svg"
exit 100
fi
filename="$1"
name=${filename%.*}
ext=${filename##*.}
echo "processing: $name"