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
require 'rmagick' | |
number_of_colors = 100 | |
file_path = "/path/to/file.jpg" | |
begin | |
temp_file = Magick::Image.read(file_path).first.quantize(number_of_colors) | |
pixels = {} | |
pixel_count = 0 | |
temp_file.each_pixel do |p,c,r| | |
pixel_count += 1 | |
pix = p.to_color(Magick::AllCompliance, false, 8) |
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
(1..100).each{|i| puts (i%3==0?'Fizz': '')+(i%5==0?'Buzz': '')+(i%3==0||i%5==0?'': i.to_s)} |
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
class HeaderCollectionViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate { | |
var collectionView : UICollectionView? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
var layout = CSStickyHeaderFlowLayout() | |
layout.parallaxHeaderReferenceSize = CGRectMake(... size of the header...) | |
layout.minimumInteritemSpacing = 0 |
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
// The image is originally animated on to the view controller then added to the scroll view. | |
// So, there might be some animation residue in here. | |
// Class needs: <UIScrollViewDelegate> | |
func viewDidLoad() { | |
let width = UIScreen.mainScreen().bounds.size.width | |
let aspect: CGFloat = width / shotWidth | |
var frame = CGRectMake(0, 0, shotWidth * aspect, shotHeight * aspect) | |
self.scrollView = UIScrollView(frame: frame) |
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
#!/bin/sh | |
# | |
# (c) 2015, Andrew Crookston <andrew@caoos.com> | |
# Licence: GPLv2 | |
# | |
# Configure it by using the pidfiles env. Format: name:pidfile name:pidfile. e.g.: | |
# | |
# [proc_mem_pid] | |
# env.pidfiles munin-node:/var/run/munin/munin-node.pid | |
# |
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
#!/bin/sh | |
# | |
# Extended 2015 by Andrew Crookston <andrew@caoos.com> to use pidfiles instead of process names | |
# Original (c) 2010, Andrew Johnstone andrew @ajohnstone.com | |
# Based on the 'proc_mem' plugin, written by Rodrigo Sieiro rsieiro @gmail.com | |
# | |
# Configure it by using the pidfiles env. Format: name:pidfile name:pidfile. e.g.: | |
# | |
# [proc_cpu_pid] | |
# env.pidfiles munin-node:/var/run/munin/munin-node.pid |
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
class Example < ActiveRecord::Base | |
include WithoutTimestamps | |
def update_something | |
update_without_timestamps something: "is changed" | |
end | |
def alternatively | |
self.something = "is changed" | |
update_without_timestamps |
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
// | |
// StretchCollectionViewFlowLayout.swift | |
// | |
// Created by Andrew C on 5/8/15. | |
// | |
import UIKit | |
class StretchCollectionViewFlowLayout: UICollectionViewFlowLayout { |
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
[core] | |
excludesfile = /Users/!!!INSERT YOUR COMPUTER USERNAME!!!/.gitignore | |
[push] | |
default = current | |
[color] | |
ui = true | |
[user] | |
name = !!!INSERT YOUR NAME!!! | |
email = !!!INSERT YOUR EMAIL!!! | |
[github] |
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
// | |
// SecureKeyValue.swift | |
// | |
// Created by Andrew Crookston <andrew@caoos.com> on 1/5/16. | |
// Copyright © 2016. License: MIT. | |
// | |
import Foundation | |
import Locksmith |