Skip to content

Instantly share code, notes, and snippets.

View rorhug's full-sized avatar
📀
out on dvd

Rory Hughes rorhug

📀
out on dvd
View GitHub Profile
@rorhug
rorhug / gist:9177147
Created February 23, 2014 20:55
dokku troublshoot
~/dokku
total 56
-rw-r--r-- 1 root root 732 Feb 23 18:36 AUTHORS
-rw-r--r-- 1 root root 738 Feb 23 18:36 bootstrap.sh
drwxr-xr-x 2 root root 4096 Feb 23 18:36 contrib
drwxr-xr-x 2 root root 4096 Feb 23 18:36 docs
-rwxr-xr-x 1 root root 3032 Feb 23 18:36 dokku
-rw-r--r-- 1 root root 845 Feb 23 18:36 HISTORY.md
-rw-r--r-- 1 root root 1055 Feb 23 18:36 LICENSE
-rw-r--r-- 1 root root 2072 Feb 23 18:36 Makefile
@rorhug
rorhug / search.sql
Created April 1, 2014 16:51
Postgres full text search example
# Note Load (30.9ms)
SELECT "notes".*, (
(ts_rank(
(
to_tsvector('english', unaccent(
coalesce("notes"."title"::text, '')
)) || to_tsvector('english', unaccent(
coalesce("notes"."short_text"::text, '')
))
@rorhug
rorhug / tco.rb
Created April 6, 2014 17:31
Ruby tail recursion
RubyVM::InstructionSequence.compile_option = {
:tailcall_optimization => true,
:trace_instruction => false
}
/var/folders/2m/1tctt7mj4lzbq_qzj5dtltr40000gn/T/ruby-build.20140818110316.52342 ~
HTTP/1.1 200 OK
Content-Type: binary/octet-stream
Content-Length: 15092388
Connection: keep-alive
Date: Mon, 30 Jun 2014 03:05:59 GMT
Last-Modified: Fri, 23 May 2014 08:34:00 GMT
ETag: "e57fdbb8ed56e70c43f39c79da1654b2"
Accept-Ranges: bytes
Server: AmazonS3
@rorhug
rorhug / music.js
Created August 24, 2014 08:39
Bayan music
// SETTINGS
var input = "rsa ecde srgu yhgr bv rsa ecde srgu yhgr bv hybtg ser erv";
input += " hybtg iii r hybtg ser erv tvr rrr rvgres rrr rvg rrr rvgres ";
input += "ggg rgh grs sxebbe cuuuhbgres grs sxebbe cbbbgvrsai";
var TIME_INTERVAL = 300;
// Add jquery
var script = document.createElement('script');
script.src = 'http://code.jquery.com/jquery-1.11.0.min.js';
script.type = 'text/javascript';
@rorhug
rorhug / dokku_pg
Created October 19, 2014 12:15
Dokku postgres installation error
# dokku plugins-install
gpg: keyring `/tmp/tmpupqa1nqp/secring.gpg' created
gpg: keyring `/tmp/tmpupqa1nqp/pubring.gpg' created
gpg: requesting key C300EE8C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpupqa1nqp/trustdb.gpg: trustdb created
gpg: key C300EE8C: public key "Launchpad Stable" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
Sending build context to Docker daemon 145.4 kB
@rorhug
rorhug / rob.c
Created December 8, 2015 14:43
for the user to input a number(Z), to place that number in a pointer and to print out the pointer outside the function
#include <stdio.h>
// This shouldn't return anything as it's writing the value to the pointer instead
void scan_int_into_pointer(int * z) // it receives a pointer to an int as an argument
{
printf("enter value=");
scanf("%d", z); // Note: no & because z is already a pointer
// Note: No return value...
}
import java.util.Scanner;
public class TriangularStars {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner( System.in );
String inputString="";
do {
System.out.print("How many star&triangle number do you want? (or 'quit')");
input = new Scanner( System.in );
@rorhug
rorhug / create_submission.rb
Created February 4, 2016 21:59
Create c submission zips for college
#!/usr/bin/env ruby
require 'fileutils'
require 'zip'
# ====== INSTRUCTIONS ====== #
# Stick this script in the folder with your programming set folders (s1, s2 etc.)
# Run `gem install rubyzip`. This will allow us to zip things
# Change the constants below and execute with ./create_submission.rb
# ====== CHANGE THESE ====== #
// Fig. 12.3: figl2_03.c
// Inserting and deleting nodes in a list
#include <stdio.h>
#include <stdlib.h>
struct listNode {
char data;
struct listNode *nextPtr;