This file contains hidden or 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
| defmodule LeakyBucket.Bucket do | |
| @moduledoc """ | |
| Simulates a leaky bucket implementation | |
| """ | |
| use GenServer | |
| @initial_amount 0 | |
| @increment_rate 1 | |
| @leak_rate 2 | |
| @leak_interval 500 |
This file contains hidden or 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
| { | |
| "Statement": [ | |
| { | |
| "Effect": "Allow", | |
| "Action": [ | |
| "s3:GetBucketLocation", | |
| "s3:GetObject", | |
| "s3:ListBucket" | |
| ], | |
| "Resource": [ |
This file contains hidden or 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
| import Cocoa | |
| class ReplaceSegue: NSStoryboardSegue { | |
| override func perform() { | |
| guard | |
| let source = sourceController as? NSViewController, | |
| let new = destinationController as? NSViewController, |
This file contains hidden or 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
| (function ($$) { | |
| // Open a console in your web browser and paste | |
| // this entire script into it. This script doesn't | |
| // phone home at any point, you have to do that | |
| // manually. Still, give it a read. | |
| // `Cmd + Opt + J` on Chrome | |
| var user; |
This file contains hidden or 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
| # Original from http://snippets.dzone.com/posts/show/4468 by MichaelBoutros | |
| # | |
| # Optimized version which uses to_yaml for content creation and checks | |
| # that models are ActiveRecord::Base models before trying to fetch | |
| # them from database. | |
| namespace :db do | |
| namespace :fixtures do | |
| desc 'Dumps all models into fixtures.' | |
| task :dump => :environment do | |
| models = Dir.glob(Rails.root + 'app/models/**.rb').map do |s| |
This file contains hidden or 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
| # Full repo: | |
| # https://gitlab.com/mwelke/rails-async-example | |
| Future = Concurrent::Future | |
| class OperationController < ApplicationController | |
| def sync | |
| ops = [1, 2, 3] | |
| ops.each do |n| |
This file contains hidden or 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
| <div class="canvas-con"> | |
| <div class="canvas-con-inner"> | |
| <canvas id="mychart" height="250px"></canvas> | |
| </div> | |
| <div id="my-legend-con" class="legend-con"></div> | |
| </div> |
This file contains hidden or 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
| NSMutableArray *arguments = [[NSMutableArray alloc] init]; | |
| [arguments addObject:[[NSBundle mainBundle] pathForResource:@"MyScript" ofType:@"py"]]; | |
| [arguments addObject:@"--verbose"]; // Any arguments you want here... | |
| NSTask* task = [[NSTask alloc] init]; | |
| task.launchPath = @"/usr/bin/python"; | |
| task.arguments = arguments; | |
| NSMutableDictionary *defaultEnv = [[NSMutableDictionary alloc] initWithDictionary:[[NSProcessInfo processInfo] environment]]; | |
| [defaultEnv setObject:@"YES" forKey:@"NSUnbufferedIO"] ; |
This file contains hidden or 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
| import UIKit | |
| let scoresStringArray : [String] = ["Mike","Tom","Bily"] | |
| let scoresDataArray = NSKeyedArchiver.archivedData(withRootObject: scoresStringArray) | |
| //Save data | |
| _ = Keychain.save(key: "scoresKey", data: scores) | |
| //Load data | |
| if Keychain.load(key: "scoresKey") != nil{ |
This file contains hidden or 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
| import AppKit | |
| class PreferencesViewController: NSTabViewController { | |
| private lazy var tabViewSizes: [NSTabViewItem: NSSize] = [:] | |
| override func tabView(_ tabView: NSTabView, didSelect tabViewItem: NSTabViewItem?) { | |
| super.tabView(tabView, didSelect: tabViewItem) | |
| if let tabViewItem = tabViewItem { |