Skip to content

Instantly share code, notes, and snippets.

View ssoroka's full-sized avatar
👾

Steven Soroka ssoroka

👾
View GitHub Profile
@ssoroka
ssoroka / LineProtocolPayload.txt
Last active July 29, 2020 19:19 — forked from shantanoo-desai/LineProtocolPayload.txt
telegraf configuration file that connects to Mosquitto Open broker and pushes data into InfluxDB v1.x
# IOT/sensor2/temp
env,type=A temp=23.39
env,type=B temp=40.00
# IOT/sensor1/acc
env,type=A x=0.2
env,type=B x=1.3
@ssoroka
ssoroka / patch.diff
Last active August 8, 2019 04:22
golang.org/x/text go modules WIP
diff --git a/cmd/gotext/common.go b/cmd/gotext/common.go
index 51322db..03e85db 100644
--- a/cmd/gotext/common.go
+++ b/cmd/gotext/common.go
@@ -6,16 +6,6 @@ package main
import (
"fmt"
- "go/build"
- "go/parser"
@ssoroka
ssoroka / extension.js
Last active July 24, 2019 18:42
upgrade to dark slack.
// First make sure the wrapper app is loaded
document.addEventListener("DOMContentLoaded", function() {
// Then get its webviews
let webviews = document.querySelectorAll(".TeamView webview");
// Fetch our CSS in parallel ahead of time
const cssPath = 'https://raw.githubusercontent.com/Nockiro/slack-black-theme/master/custom.css';
let cssPromise = fetch(cssPath).then(response => response.text());
upstream unicorn {
server unix:/var/run/.unicorn.sock fail_timeout=0;
}
server {
listen 80 default_server deferred;
server_name example.com;
root /home/username/apps/projectname/current/public;
location ^~ /assets/ {
@ssoroka
ssoroka / unicorn_init.sh
Last active August 29, 2015 13:58
for use with curl | sed
#!/bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Manage unicorn server
# Description: Start, stop, restart unicorn server for a specific application.
### END INIT INFO
@ssoroka
ssoroka / user.js.coffee
Last active December 21, 2015 12:48
a "method_missing" example in ember.js. Catch setting undefined properties and serialize them to an "optionsString" property as a string of JSON.
App.User = DS.Model.extend
name: DS.attr 'string'
email: DS.attr 'string'
# dynamically defined properties are serialized as a string of JSON here:
optionsString: DS.attr 'string'
# optionsData lets us deal with the string as a JSON object
optionsData: ((k,v) ->
if arguments.length == 2
@set('optionsString', JSON.stringify(v))
@ssoroka
ssoroka / state_machine.rb
Created August 22, 2013 03:35
State machine in < 100 lines of ruby. No guards. (could be implemented trivially)
module StateMachine
def self.included(klass)
klass.send(:extend, ClassMethods)
klass.instance_eval do
after_initialize :set_initial_state
end
end
module ClassMethods
def state_column
App.SortedElementsView = Ember.View.extend Ember.TargetActionSupport,
target: Ember.computed.alias('controller')
action: 'sort'
classNames: ['sorted-elements']
attributeBindings: ['id', 'fields']
elementClass: 'sortable-element'
didInsertElement: () ->
elements = ".#{@get('elementClass')}"
Em.run.next () =>
hookupSortable = () =>
@ssoroka
ssoroka / gist:5824696
Last active December 18, 2015 18:19
Ember issues.

ember issues

  • update docs that use {{#each controller}} to {{#each model}} and/or explain the difference.
  • assert errors or log debug info when templates reference undefined attributes in development
  • need larger project examples of ember in live use for a production application. docs are inconsistent and too shallow on scope
  • Horrible gotchya: Passing a second argument to {{render}} creates a new controller (like {{control}} would) rather than reusing the existing one (without warning or documentation). This makes perfect sense once you understand it, but there's no indication that this is happening except that properties you set on the controller are missing. I'd love a developer mode that tells you everything Ember is generating silently for you (controllers, routes, new instances, missing attributes, etc)
  • defining a route with nothing in it is not the same as the auto generated one (it overwrites the default setupController or model?). No ideas why.
  • attributes absolutely need a readOn
@ssoroka
ssoroka / eyes.rb
Created April 11, 2013 03:09
If we know the odds of parents having children with certain eye colors, and the current eye color distributions, we can simulate random generations and see what happens! http://www.statisticbrain.com/eye-color-distribution-percentages/ https://twitter.com/scienceporn/status/322099933484314624
# given eye color distribution from:
# http://www.statisticbrain.com/eye-color-distribution-percentages/
# ignoring the yellow specs, basically:
# blue 32%, green 12%, brown 41% = 85%
# thus..
# blue 38%, green 14%, brown 48% = 100%
#
# also given the image from here..
# https://twitter.com/scienceporn/status/322099933484314624
#