Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / stock-ticker.sh
Created October 3, 2012 16:37
Realtime Stock Ticker, using Google's API
#!/bin/bash
# Real-Time stock ticker script, using Google's API
# Copyright (C) 2012 Calvin Owens
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
@nagachika
nagachika / .gitignore
Created May 29, 2015 02:57
picasa with OAuth 2.0
/.bundle
/vendor/bundle
/.envrc
@almost
almost / models.coffee
Created November 26, 2011 20:02
The beginnings of a declarative model syntax for CoffeeScript.
# The beginnings of a declarative model syntax for CoffeeScript.
# SEE: http://almostobsolete.net/declarative-models-in-coffeescript.html
# Thomas Parslow
# Email: tom@almostobsolete.net
# Twitter: @almostobsolete
# The top part is the setup, see below that for the demo
# To see this run right away try copy pasting it into the 'Try
# CoffeeScript' box at http://jashkenas.github.com/coffee-script/

A future version of Ember will come with a new templating engine known as HTMLBars.

The original motivation for HTMLBars was to allow helpers and properties to have better contextual information about what they were bound to.

So for example, consider a template like this:

<a href="{{url}}">{{link}}</a>
@stolinski
stolinski / mockMang.js
Created April 9, 2018 17:27
Level Up Tutorials MockMang
import { makeExecutableSchema, addMockFunctionsToSchema } from 'graphql-tools';
import { graphql } from 'graphql';
import GraphQLMock from 'graphql-mock';
import typeDefs from 'imports/startup/both/typeDefs';
// Make a GraphQL schema with no resolvers
const schema = makeExecutableSchema({ typeDefs });
// Creates random id
const revisedRandId = () =>
@mitio
mitio / deploy.rb
Created August 23, 2013 15:38
Sidekiq + Capistrano + Ubuntu Upstart
# config/deploy.rb
namespace :upstart do
desc 'Generate and upload Upstard configs for daemons needed by the app'
task :update_configs, except: {no_release: true} do
upstart_config_files = File.expand_path('../upstart/*.conf.erb', __FILE__)
upstart_root = '/etc/init'
Dir[upstart_config_files].each do |upstart_config_file|
config = ERB.new(IO.read(upstart_config_file)).result(binding)
@sashazykov
sashazykov / bitcoin_address_validator.rb
Created January 9, 2013 09:04
Rails 3 bitcoin address validator. Validator syntaxis: validates :address, :bitcoin_address => true, :presence => true
require 'digest'
class BitcoinAddressValidator < ActiveModel::EachValidator
def validate_each(record, field, value)
unless value.blank? || valid_bitcoin_address?(value)
record.errors[field] << "Bitcoin address is invalid"
end
end
private
@anton-rudeshko
anton-rudeshko / convert.sh
Last active October 17, 2020 01:01
Convert GoPro photos to timelapse video using ffmpeg CLI.
#!/usr/bin/env bash
# -r 60: 60 FPS
# -y: rewrite output file
# -start_number 11555: first frame number
# -i 'G%07d.JPG': file format
# -vf "crop=h=2250": video filter to crop input frame height from 3000 to 2250 (which will be eventually downscaled to 720)
# -c:v libx264: video codec x264
# -crf 20: x264 encoding quality (less = better)
# -s 1280x720: output size
@dawsontoth
dawsontoth / restartTerminal.sh
Created December 6, 2012 15:30
osascript to focus terminal, send ctrl+c, then up, then enter.
tell application "System Events"
tell application "Terminal" to activate
keystroke "c" using {control down}
key code 126
key code 52
end tell
@jareware
jareware / s3-curl-backups.md
Last active August 29, 2021 00:56
Simple, semi-anonymous backups with S3 and curl

⇐ back to the gist-blog at jrw.fi

Simple, semi-anonymous backups with S3 and curl

Backing stuff up is a bit of a hassle, to set up and to maintain. While full-blown backup suites such as duplicity or CrashPlan will do all kinds of clever things for you (and I'd recommend either for more complex setups), sometimes you just want to put that daily database dump somewhere off-site and be done with it. This is what I've done, with an Amazon S3 bucket and curl. Hold onto your hats, there's some Bucket Policy acrobatics ahead.

There's also a tl;dr at the very end if you just want the delicious copy-pasta.

Bucket setup