This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def gen_primes(n) | |
sieve = Array.new(n) { |i| i > 1 } | |
(0...Math.sqrt(n)).each do |i| | |
next unless sieve[i] | |
(i * i...n).step(i) { |j| sieve[j] = false } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# split head and tail | |
(head, *tail) = [1, 2, 3] | |
# head is 1 | |
# tail is [2, 3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Convert an animated video to gif | |
# Works best for videos with low color palettes like Dribbble shots | |
# | |
# @param $1 - video file name like `animation.mov` | |
# @param @optional $2 - resize parameter as widthxheight like `400x300` | |
# | |
# Example: vidtogif animation.mov 400x300 | |
# Requirements: ffmpeg and gifsicle. Can be downloaded via homebrew |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text.RegularExpressions; | |
using UnityEngine; | |
using UnityEngine.UI; | |
// Usage: icon name in text is replaced by image | |
public class TextPic : Text | |
{ | |
[System.Serializable] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lerp(start, stop, step) | |
(stop * step) + (start * (1.0 - step)) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Entitas { | |
/// Inherit from this class if you want a component that is just a wrapper for some type. | |
/// All attributes that work for normal components also work for components that inherit from this class. | |
/// The body of the inheriting class should remain empty. | |
/// Example use: | |
/// <example> | |
/// // definition | |
/// public class NameComponent : WrapperComponent<string> { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# find /Applications -path '*Autoupdate.app/Contents/Info.plist' -exec echo {} \; -exec grep -A1 CFBundleShortVersionString '{}' \; | grep -v CFBundleShortVersionString | |
find /Applications/ -path '*Sparkle.framework*/Info.plist' -exec echo {} \; -exec grep -A1 CFBundleShortVersionString '{}' \; | grep -v CFBundleShortVersionString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env runhaskell | |
maximum' :: (Ord a) => [a] -> a | |
maximum' [] = error "maximum of empty list" | |
maximum' [x] = x | |
maximum' (x:xs) = max x (maximum' xs) | |
main :: IO () | |
main = do | |
-- print (maximum' [3, 5, 7, 3, 6]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Need to forward declare this symbol to use it in fib | |
(declare memo-fib) | |
(defn fib | |
"Returns the fibonacci number for the given position." | |
[n] | |
(if (or 0 1) | |
n | |
(+' (memo-fib (-' n 1)) (memo-fib (-' n 2))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
## | |
# Markdown summarizer for Pivotal stories | |
# | |
# Usage './pivotal_story_summary.rb <project-id> <username>' | |
# | |
# | |
# The MIT License (MIT) |