Skip to content

Instantly share code, notes, and snippets.

View bmcculley's full-sized avatar

bmcculley

View GitHub Profile
@bmcculley
bmcculley / testCurl.php
Last active August 29, 2015 14:07
Test if a server has curl on it or not
<?php
function _isCurl() {
return function_exists('curl_version');
}
if ( _isCurl() ) {
echo 'cURL is installed on this server :-)';
} else {
echo 'You\'ll need cURL for this...';
@bmcculley
bmcculley / oneliners
Created November 6, 2014 04:15
Gonna keep all my sweet one liners here, more to come soon
delete all lines from nw.txt containing snatch
perl -pi -e 'if(/snatch/){undef $_}' nw.txt
/*************************************************************************
* Compilation: javac HelloWorld.java
* Execution: java HelloWorld
*
* Prints "Hello, World". By tradition, this is everyone's first program.
*
* % java HelloWorld
* Hello, World
*
* These 17 lines of text are comments. They are not part of the program;
<?xml version="1.0" encoding="UTF-8"?>
<yahoo-weather-codes>
<code number="0" description="tornado"/>
<code number="1" description="tropical storm"/>
<code number="2" description="hurricane"/>
<code number="3" description="severe thunderstorms"/>
<code number="4" description="thunderstorms"/>
<code number="5" description="mixed rain and snow"/>
<code number="6" description="mixed rain and sleet"/>
<code number="7" description="mixed snow and sleet"/>
@bmcculley
bmcculley / app.py
Created November 15, 2014 05:10
Some basic tornado authentication
#!/usr/bin/env python
import tornado.auth
import tornado.escape
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
class BaseHandler(tornado.web.RequestHandler):
def get_current_user(self):
#!/bin/bash
if [ -e /usr/bin/python ]
then
echo "Python found!"
else
echo "Python missing!"
fi
chmod cheat sheet
PERMISSION COMMAND
U G W
_____________________________________
|rwx rwx rwx chmod 777 <filename> |
|_____________________________________|
|rwx rwx r-x chmod 775 <filename> |
|_____________________________________|
@bmcculley
bmcculley / gist:f3e94607090540a2c0e0
Created December 21, 2014 07:22
Python pretty print with thousands separators
import locale
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
def pp(num):
return locale.format("%d", num, grouping=True)
# test print
print pp(10000)
@bmcculley
bmcculley / gist:e8c93c84ceb46ba59303
Last active August 29, 2015 14:12
Download SVN repositories without having SVN installed on the host machine
wget -m -np http://project.googlecode.com/svn/project/trunk/

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname