Skip to content

Instantly share code, notes, and snippets.

View valer-cara's full-sized avatar
📡
stay tuned

Valer Cara valer-cara

📡
stay tuned
View GitHub Profile
@tgk
tgk / swing.clj
Created October 8, 2012 17:09
A Swing example in Clojure
(ns swing
(:import [javax.swing JFrame JLabel JButton]
[java.awt.event WindowListener]))
(defn swing []
(let [frame (JFrame. "Fund manager")
label (JLabel. "Exit on close")]
(doto frame
(.add label)
(.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
@domenic
domenic / promises.md
Last active June 24, 2024 03:11
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@pwenzel
pwenzel / internet_radio_stream_aliases.sh
Created October 23, 2012 15:16
Internet Radio Streams Via Command Line
# 1. Install mplayer command line (via Brew, Macports, or APT)
# 2. Add the following aliases to ~/.profile
# 3. Type `source ~/.profile`
# 3. Type `news` or `current` to listen in your terminal
alias news="mplayer -playlist http://minnesota.publicradio.org/tools/play/streams/news.pls" # MPR News
alias current="mplayer -playlist http://minnesota.publicradio.org/tools/play/streams/the_current.pls" # The Current
alias classical="mplayer -playlist http://minnesota.publicradio.org/tools/play/streams/classical.pls" # Classical MPR
alias localcurrent="mplayer -playlist http://minnesota.publicradio.org/tools/play/streams/local.pls" # Local Current
alias heartland="mplayer -playlist http://minnesota.publicradio.org/tools/play/streams/radio_heartland.pls" # MPR Radio Heartland
@patcon
patcon / Description.md
Created November 1, 2012 17:54
Using sox CLI tool to gather metrics on ambient volume in room

Running this on OSX, so need to install sox first:

brew install sox

Then paste this file somewhere, and run it in the background with:

bash monitor-audio-levels.sh

As of right now, it only add a character to /tmp/threshold-tally.txt for every 5-second interval where volume exceeds the arbitrary "3" threshold. Would be really useful to timestamp each, and convert to JSON that we can send to a custom leftronic.com dashboard widget, and get a rough idea of how much of the day a room's volume exceeds a given threshold.

@ivanvanderbyl
ivanvanderbyl / account_routes.js
Last active January 31, 2016 17:55
Using Ember initializers and injections to setup the `currentUser` within your app.
App.AccountEditRoute = Ember.Route.extend({
setupController: function(controller) {
controller.set('content', this.get('currentUser'));
}
});
@evilmarty
evilmarty / README.md
Last active December 14, 2015 13:39
Ember-backed autocomplete

In my journey in figuring out the Ember pattern, this is my attempt at trying to create an Ember-only autocomplete field. There were a few outcomes I wanted out of this, a part from being the Ember-way:

  • Work with any data source
  • Easily templatable results
  • Use only Ember constructs

All are welcome to use this, I'm just after feedback at this point.

@bunnymatic
bunnymatic / custom_array_matchers.rb
Last active July 3, 2020 21:24
RSpec Matchers for increasing/decreasing array tests. Useful when sort may not be the easiest way to do things.
RSpec::Matchers.define :be_monotonically_increasing do
match do |actual|
derivative = actual.each_cons(2).map{|x, y| y <=> x}
derivative.all?{|v| v >= 0}
end
failure_message_for_should do |actual|
"expected array #{actual.inspect} to be monotonically increasing"
end
@sebastianseilund
sebastianseilund / merged_array.js
Last active December 20, 2015 07:58
An implementation of a merged array in Ember.js that combines items from multiple source arrays so you can easily list them together in your Handlebars templates. Read the blog post at the [Billy's Billing Developer Blog](http://dev.billysbilling.com/blog/How-to-merge-multiple-data-sources-into-one-array-in-Ember-js)
/**
* `Ember.MergedArray` is an array that observes multiple other arrays (called source arrays) for changes and includes
* all items from all source arrays in an efficient way.
*
* Usage:
*
* ```javascript
* var obj = Ember.Object.create({
* people: [
* {
@GavinJoyce
GavinJoyce / gist:6403776
Created September 1, 2013 11:06
Run Loop Metrics Bookmarklet
javascript:(function(){
var getTimestamp = function() { return new Date().getTime(); };
if (window.performance.now) {
getTimestamp = function() { return window.performance.now(); };
} else if (window.performance.webkitNow) {
getTimestamp = function() { return window.performance.webkitNow(); };
}
var startTime, endTime, loopCount = 0;
@denji
denji / http-benchmark.md
Last active July 18, 2024 09:01
HTTP(S) Benchmark Tools / Toolkit for testing/debugging HTTP(S) and restAPI (RESTful)