Skip to content

Instantly share code, notes, and snippets.

View world.sql
CREATE TABLE City (
ID BIGSERIAL,
Name varchar(35) NOT NULL DEFAULT '',
CountryCode varchar(3) NOT NULL DEFAULT '',
District varchar(20) NOT NULL DEFAULT '',
Population int NOT NULL DEFAULT '0'
)
;
@sandfox
sandfox / README.md
Last active Sep 19, 2018
Simple example upstart config for nodejs
View README.md

This example assumes your running a recent Ubuntu with upstart installed and you have install n from npm.

To see an example use of this ina a wider context, look at this gist for deploying node.js + nginx

Adapt as required.

  1. Put the node.conf in /etc/init/
  2. Create a folder for individual site configs to live in /etc/node
  3. Put the node-test.conf inside /etc/node
  4. Create the folder for the logs /var/logs/node
@jhgaylor
jhgaylor / through_relationships.py
Last active Jul 30, 2021
Example of using a through model in Django and filtering by a value on the custom through model.
View through_relationships.py
class A(models.Model):
things = models.ManyToManyField("B", through=ThroughModel)
class B(models.Model):
text = models.TextField()
class ThroughModel(models.Model):
a = models.ForeignKey(A)
b = models.ForeignKey(B)
extra = models.BooleanField()
@irazasyed
irazasyed / Install Composer using MAMP's PHP.md
Last active Jul 31, 2021
Instructions on how to change preinstalled Mac OS X PHP to MAMP's PHP Installation and then install Composer Package Management
View Install Composer using MAMP's PHP.md

Change default Mac OS X PHP to MAMP's PHP Installation and Install Composer Package Management


Instructions to Change PHP Installation


First, Lets find out what version of PHP we're running (To find out if it's the default version).

To do that, Within the terminal, Fire this command:

which php
@asugai
asugai / Install composer on Amazon AMI running on EC2
Last active Jul 26, 2021
Install composer on Amazon AMI running on EC2
View Install composer on Amazon AMI running on EC2
$ cd ~
$ sudo curl -sS https://getcomposer.org/installer | sudo php
$ sudo mv composer.phar /usr/local/bin/composer
$ sudo ln -s /usr/local/bin/composer /usr/bin/composer
then you can run
$ sudo composer install
@irazasyed
irazasyed / homebrew-permissions-issue.md
Last active Jul 31, 2021
Homebrew: Permissions Denied Issue Fix (OS X / macOS)
View homebrew-permissions-issue.md

Homebrew Permissions Denied Issues Solution

sudo chown -R $(whoami) $(brew --prefix)/*

@ARolek
ARolek / ImageMagick-Amazon-Linux.md
Last active May 14, 2021
Install ImageMagick from source on Amazon Linux
View ImageMagick-Amazon-Linux.md

I needed a newer version of ImageMagick than is available on the yum packages on Amazon Linux. I tried using the remi repo but it failed with dependency errors. Here is what I did to install ImageMagick with support for PNG, JPG, and TIFF.

download the most recent package

wget http://www.imagemagick.org/download/ImageMagick.tar.gz

uncomress the package

@joecliff
joecliff / cryptojs_base64_encrypt_decrypt.js
Last active Jul 12, 2021
An example of base64 usage in cryptojs
View cryptojs_base64_encrypt_decrypt.js
var CryptoJS = require("crypto-js");//replace thie with script tag in browser env
//encrypt
var rawStr = "hello world!";
var wordArray = CryptoJS.enc.Utf8.parse(rawStr);
var base64 = CryptoJS.enc.Base64.stringify(wordArray);
console.log('encrypted:', base64);
//decrypt
var parsedWordArray = CryptoJS.enc.Base64.parse(base64);
@mauris
mauris / queue-ensure.php
Created Apr 28, 2014
Laravel Artisan Queue Ensurer - Set a cron job to run this file periodically to ensure that Laravel's queue is processing all the time. If the queue listener stopped, restart it!
View queue-ensure.php
<?php
function runCommand ()
{
$command = 'php artisan queue:listen > /dev/null & echo $!';
$number = exec($command);
file_put_contents(__DIR__ . '/queue.pid', $number);
}
if (file_exists(__DIR__ . '/queue.pid')) {