Skip to content

Instantly share code, notes, and snippets.

View alenm's full-sized avatar

Alen Mujkic alenm

View GitHub Profile
@stevestreza
stevestreza / DispatchQueueScheduler.swift
Last active June 29, 2023 13:06
A basic implementation of a Scheduler for Combine. Probably not a great implementation. Useful only as a toy, do not ship this.
//
// DispatchQueueScheduler.swift
//
import Combine
import Foundation
// DO NOT USE THIS IN PRODUCTION
struct DispatchQueueScheduler: Scheduler {
let queue: DispatchQueue
@vincentbello
vincentbello / timer.js
Created October 8, 2016 19:43
app/services/timer.js
// General purpose timer service
import Ember from 'ember';
export default Ember.Service.extend({
interval: 5000,
// Schedules function `f` to be executed on interval
schedule(f, interval) {
const time = interval || this.get('interval');
return Ember.run.later(this, function() {
@moklett
moklett / task1.exs
Last active May 7, 2024 09:59
Elixir Task - Crash Handling
# This demonstrates that, when using async/await, a crash in the task will crash the caller
defmodule Tasker do
def good(message) do
IO.puts message
end
def bad(message) do
IO.puts message
raise "I'm BAD!"
end
@atika
atika / SecondsToDaysHoursMinutesSeconds.swift
Created March 10, 2016 09:55
Convert seconds to days, hours, minutes, seconds in Swift
let seconds = 86400*4 + 3600*2 + 65
print(String((seconds / 86400)) + " days")
print(String((seconds % 86400) / 3600) + " hours")
print(String((seconds % 3600) / 60) + " minutes")
print(String((seconds % 3600) % 60) + " seconds")
@squarism
squarism / iterm2.md
Last active May 6, 2024 22:59
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@stevedomin
stevedomin / create_post.exs
Last active July 12, 2023 01:32
Using UUIDs as primary key with Ecto
defmodule MyBlog.Repo.Migrations.CreatePost do
use Ecto.Migration
def change do
create table(:posts, primary_key: false) do
add :id, :uuid, primary_key: true
add :body, :string
add :word_count, :integer
timestamps
@poteto
poteto / search.js
Last active January 24, 2017 19:52
simple text search computed property macro
// utils/computed/search.js
import Ember from 'ember';
var computed = Ember.computed;
export default function search(dependentKey, propertyKey, searchQueryKey, returnEmptyArray) {
returnEmptyArray = (typeof returnEmptyArray === "undefined") ? false : returnEmptyArray;
return computed("" + dependentKey + ".@each." + propertyKey, searchQueryKey, function() {
var items, query;
if (returnEmptyArray && !this.get(searchQueryKey)) {
return Ember.A([]);

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

//
// OLD AND BUSTED
//
if ([self.zoomingDelegate respondsToSelector:@selector(zoomingWindow:didZoomOutViewController:)] == YES)
{
// Do something important.
}
//
@jpo
jpo / progress_indicators.rb
Created July 31, 2012 02:23
Ruby CLI Progress Indicators
# Terminal Progress Indicators. Four examples are included: percentage,
# spinner, progress bar, and combined. This script has been tested on
# Mac OS X 10.8 with Ruby 1.8.7, 1.9.1, 1.9.2, and 1.9.3
class Spinner
include Enumerable
def each
loop do
yield '|'
yield '/'