Skip to content

Instantly share code, notes, and snippets.

@fnichol
fnichol / README.md
Created March 12, 2011 20:52
Download a cacert.pem for RailsInstaller

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@oodavid
oodavid / README.md
Last active April 6, 2024 18:45 — forked from aronwoost/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@hm2k
hm2k / leftshift32
Created May 13, 2012 20:25
Performs a 32-bit left shift operation (<<) even on a 64-bit machine
/**
* Performs a 32-bit left shift operation (<<) even on a 64-bit machine
*
* @param integer $number Shift these bits
*
* @param integer $steps Step this many times
*
* @return string Returns the integer
*/
function leftshift32 ($number, $steps)
@gialloporpora
gialloporpora / imgur.bat
Created June 12, 2012 21:53
Upload image on ImgUr (anonymous) with history using commandline. It requires sed and curl.
@echo off
REM Set you API KEY http://imgur.com/register/api_anon
set apikey=your_apikey_here
REM Usage:
REM img file_path [title] [caption]
REM img url [title] [caption]
REM title and caption are optional, quote them if they contains spaces or strange characters
REM Set the path where are located curl.exe and sed.exe
@snipe
snipe / build-ant-phpunit
Created November 22, 2012 21:08
Apache Ant build.xml file for PHPUnit+Jenkins+Ant+Zend Framework
<?xml version="1.0" encoding="UTF-8"?>
<!-- Set some basic project information and targets -->
<project name="My ZF Project" default="build">
<target name="build"
depends="prepare, lint, phploc, phpmd, phpcpd, phpcs, phpunit"/>
<target name="build-parallel"
depends="prepare,lint, tools-parallel, phpcpd, phpunit"/>
@tPl0ch
tPl0ch / build.xml
Created December 2, 2012 03:51
Ant build file for PHP projects including Behat build task
<?xml version="1.0" encoding="utf-8"?>
<project name="your-project-name-here" default="build">
<target name="build"
depends="prepare,lint,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpdox,phpunit,behat,phpcb"/>
<target name="build-parallel"
depends="prepare,lint,tools-parallel,phpunit,phpcb"/>
<target name="tools-parallel" description="Run tools in parallel">
<parallel threadCount="2">
@jpswade
jpswade / gist:4571750
Created January 19, 2013 10:06
How do you remove numbers from a string in PHP?
<?php
$string = 'abc123';
$string = str_replace(range(0,9), '', $string);
echo $string;
/* http://codepad.org/AYECJrbZ */
?>
@jeffreybarke
jeffreybarke / ci-encryption-key-generator.php
Created April 9, 2013 17:21
This is the code I use (minus Google Analytics) for the CodeIgniter encryption key generator located at http://jeffreybarke.net/tools/codeigniter-encryption-key-generator/
<?php
/**
* Generate an encryption key for CodeIgniter.
* http://codeigniter.com/user_guide/libraries/encryption.html
*/
// http://www.itnewb.com/v/Generating-Session-IDs-and-Random-Passwords-with-PHP
function generate_token ($len = 32)
{
@stonehippo
stonehippo / RPi-Dashing-howto.md
Last active October 6, 2021 13:52
Setting up a Raspberry Pi as a dashboard server with Dashing

Setting up a Raspberry Pi as a dashboard server with Dashing

Why the heck did I do this?

I wanted to set up one of my Raspberry Pi's as a data dashboard, pushing sensor data to a web interface that's easy to digest. I decided to use Shopify's Dashing framework. Dashing is based on Sinatra, and is pretty lightweight.

Dashing does require Ruby 1.9.3 to run. In addition, it makes use of the execjs gem, which needs to have a working Javascript interpreter available. Originally, I tried to get therubyracer working, but decided to switch over to Node.js when I ran into roadblocks compiling V8.

One warning: The RPi is a very slow system compared with modern multi-core x86-style systems. It's pretty robust, but compiling all this complex software taxes the system quite a bit. Expect that it's going to take at least half a day to get everything going.