Skip to content

Instantly share code, notes, and snippets.

View dideler's full-sized avatar

Dennis Ideler dideler

View GitHub Profile
@SumuduF
SumuduF / cake_cutting.py
Last active December 12, 2015 08:59
Solutions for Facebook Hacker Cup Round 2 I got stuck on problem 2 during the actual round due to a bit of a nasty off-by-one error (fixed below); in retrospect it would have been better to try #3 to have a chance at qualifying. Added solution to problem #3; essentially a standard DP on a tree + a bit of cleverness to ensure proper counting. Dur…
import sys
def main():
for (i, (n, a)) in enumerate(testcases()):
print "Case #{0}: {1}".format(i+1, regions(n, a))
def testcases(cin=sys.stdin):
nc = int(cin.next())
for _ in xrange(nc):
nums = map(int, cin.next().split())
@SumuduF
SumuduF / card_game.py
Created February 3, 2013 21:30
Solutions for Facebook Hacker Cup 2013 / Round 1 No explanations for now...
import sys
MOD = 1000000007
def main():
for (i, (n, k, cards)) in enumerate(testcases()):
print "Case #{0}: {1}".format(i+1, subsum(n, k, cards))
def testcases(cin=sys.stdin):
m = int(cin.next())
@fosslc
fosslc / Freeseer.md
Created November 30, 2012 23:21
Freeseer project

Overview

The Freeseer project is a powerful software suite for capturing video. It enables you to capture great presentations, demos, training material, and other videos. It handles desktop screen-casting with ease. It is one of a few such tools that can also record vga output. It is particularly good at handling large conferences with hundreds of talks. Freeseer can run on a laptop with commodity hardware such as a web cam, camcorder, or vga capture device. The resulting system fits easily into a laptop and can be assembled in under 10 minutes to record any number of presentations/demos/talks.

Freeseer is implemented in Python, uses Qt for its GUI, and quite approachable and easy to learn the code base given it's clear structure and reasonable size (17K lines of code). One can make a significant contribution to Freeseer, perhaps more than many other open source projects.

Freeseer is the best software available for recording large conferences. We have put a lot of thought and automation into work flow to

@minitech
minitech / web-checklist.md
Last active January 4, 2020 11:59
minitech’s Web Checklist

minitech’s Web Checklist

Here are some guidelines that will make me actually like your amazing new web application!

  1. Make sure encoding is handled properly every step of the way. If comes out as ’, you’ve got a problem on your hands. 😊

  2. Make it accessible. Turn off images, JavaScript, and CSS. If your website is still legible and usable (it’s okay if it’s just barely usable, or not particularly interactive) then you are already in the top 0.01%.

  3. Check your grammar. One of the fastest ways to lose respect in a blog post (or worse — in body copy) is to make basic orthographical or grammatical mistakes. These include, but are not limited to:

  • Missing apostrophes — [Bitbucket even did that][bitbucket-apostrophe-catastrophe].
@nhoizey
nhoizey / screenshots.js
Created November 12, 2012 17:07
Take screenshots at different viewport sizes using CasperJS
/*
* Takes provided URL passed as argument and make screenshots of this page with several viewport sizes.
* These viewport sizes are arbitrary, taken from iPhone & iPad specs, modify the array as needed
*
* Usage:
* $ casperjs screenshots.js http://example.com
*/
var casper = require("casper").create();
@jlfwong
jlfwong / progdiff.sh
Created October 3, 2012 20:07
Diff the stdout, stderr and return code of two programs with piped input and arguments
#!/bin/bash
sandbox="$(mktemp -d)"
hasstdin=false
if [ ! -t 0 ]; then
cat <&0 > "$sandbox/stdin.txt"
hasstdin=true
fi
@uhziel
uhziel / unameh.sh
Created September 6, 2012 05:08
human version of uname
unameh()
{
echo "kernel-name: $(uname --kernel-name)"
echo "nodename: $(uname --nodename)"
echo "kernel-release: $(uname --kernel-release)"
echo "kernel-version: $(uname --kernel-version)"
echo "machine: $(uname --machine)"
echo "processor: $(uname --processor)"
echo "hardware-platform: $(uname --hardware-platform)"
echo "operating-system: $(uname --operating-system)"
@mrdoob
mrdoob / gist:3504305
Created August 28, 2012 20:58
Renaming files in a folder consecutively.
import os
for i, filename in enumerate(sorted(os.listdir("."))):
os.rename(filename, "{0}.png".format(i))
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@nebiros
nebiros / unicorn.rake
Created June 5, 2012 17:26
rails rake tasks for managing unicorn server instances + rbenv
ENV["RAILS_ENV"] ||= "production"
module UnicornServer
# http://unicorn.bogomips.org/Unicorn/Configurator.html
CONFIG_PATH = File.join(Rails.root, "config", "unicorn.rb")
PID_PATH = File.join(Rails.root, "tmp", "pids", "unicorn.pid")
RBENV = %x[which rbenv].strip
DAEMON = "bundle exec unicorn_rails"
DAEMON_OPTS = "-c #{CONFIG_PATH} -E #{ENV["RAILS_ENV"]} -D"