Skip to content

Instantly share code, notes, and snippets.

View tfogo's full-sized avatar

Tim Fogarty tfogo

View GitHub Profile
shh such algorithm
so commander as cat
plz cat.option with '-n, --number <n>' 'many number' parseInt
plz cat.parse with process.argv
such doge much nice
rly nice<1
@tfogo
tfogo / cornify.js
Last active December 31, 2015 09:39
Sparklify your web pages!
jQuery.getScript('http://www.cornify.com/js/cornify.js',function(){ for (var i = 0; i < 25; i++) cornify_add() });
@tfogo
tfogo / ex1.c
Last active January 3, 2016 01:39
Example 1
void foo(int a) { // 1 is copied to another space in memory when foo() is called
// do something
}
int main() {
int a = 1; // 1 is now in memory
foo(a);
}
@tfogo
tfogo / dummydata.js
Last active May 26, 2016 09:14
RESTful API with node.js and mongodb. `npm install` then `node server.js`
var mongoose = require('mongoose')
, Podcast = mongoose.model('Podcast');
Podcast.find({}).remove(function() {
Podcast.create({
title: 'Joe Rogan',
score: 4783,
tags: ['tag1', 'tag2', 'tag3'],
dateSubmitted: new Date
}, {
@tfogo
tfogo / JSTalk.md
Created March 2, 2014 12:59
Notes for a talk on client-side javascript I did for HackSoc Notts

JS Talk for HackSoc

1995 LiveScript released for NetScape Navigator. It was a language designed to by easy for non-programmers and to add cool dynamic functionality to websites. It ran in the web browser. These days all web browsers have JavaScript engines built in because it is the de facto scripting language of the web. Its name was quickly changed to JavaScript as a marketing ploy because Java was a very hot language at the time. But it has nothing to do with Java. The only thing it has in common is syntax because both languages have syntax based on C.

1996 JavaScript standardized by ECMA. The standard is called ECMAScript

JavaScript used to be famous for being really slow, but because of how important it is to dynamic web pages, companies like Google and Mozilla have sunk a tonne of money into making it faster. These days it's pretty fast and isn't only used in web browsers (see Node.js).

Language Basics for Beginners

@tfogo
tfogo / matlabfix.sh
Created April 5, 2014 14:54
How to fix gray screen on MATLAB using Xmonad.
wmname LG3D
@tfogo
tfogo / howtogif
Created April 8, 2014 13:19
How to convert videos to gif using ffmpeg and gifsicle
How to convert a video file to an animated GIF on Linux:
Install required software:
apt-get install ffmpeg gifsicle imagemagick:
Convert the video file to a series of small images:
mkdir /tmp/gif/
ffmpeg -i YOURVIDEOFILE.mp4 -r 10 /tmp/gif/out%04d.gif
Combine these images together into a GIF animation:
gifsicle –delay=10 –loop /tmp/gif/*.gif > animation.gif
Optimise the GIF animation so the file size is smaller:
@tfogo
tfogo / videosplit.sh
Created July 25, 2014 08:03
Split long videos into 2 minute segments
#!/bin/bash
FILES=/home/tim/Videos/marathon-vids/*.mp4
for f in $FILES
do
time="$(avprobe "$f" 2>&1 >/dev/null | grep -Po '(?<=Duration:\s)\d{2}:\d{2}:\d{2}')"
hrs="$(echo "$time" | grep -Po '\d{2}(?=:\d{2}:\d{2})')"
mins="$(echo "$time" | grep -Po '(?<=\d{2}:)\d{2}(?=:\d{2})')"
secs="$(echo "$time" | grep -Po '(?<=\d{2}:\d{2}:)\d{2}')"
filename="$(echo "$f" | grep -Po '(?<=/home/tim/Videos/marathon-vids/).*(?=\.mp4)')"
let time=$hrs*3600+$mins*60+$secs
var mongoose = require('mongoose');
// config
var config = require('./config');
// mongodb URI
var uristring = config.db;
// connect to db
mongoose.connect(uristring);
@tfogo
tfogo / video-annotator-instructions.md
Last active August 29, 2015 14:06
Video annotator setup instructions

The videos are on the machine at the end of the hotdesk area in the MRL. The machine should be on and an ubuntu VM should be running. If not, please start the VM using VirtualBox.

Check that /media/sf_marathon/videos/ exists and contains all the marathon videos. If this isn't the case, you'll have to share C:\marathon with the guest OS using VirtualBox. Make sure the directory /media/sf_marathon/videos/output exists. If it does not, create it.

Change to the video annotator's directory.

$ cd ~/p/video-annotator

Pull the branch origin/server from https://github.com/tfogo/video-annotator.git