Skip to content

Instantly share code, notes, and snippets.

View StefanWallin's full-sized avatar
🌍
💚

Stefan Wallin StefanWallin

🌍
💚
View GitHub Profile
@StefanWallin
StefanWallin / protocol.md
Created December 4, 2013 18:53
LoungeChatProtocol - version 1, draft 9

Protocol Introduction

Thinking about the protocol, I'm thinking about extendability. The client should be able to present commands it knows during handshake. Each feature of the API should have a version that is supported.

All commands should have three top level entries in it's envelope:

  • c — command is a string representation of the command you whish to execute through RPC. Max length of this parameter is 20 byte characters
  • t — a server generated token specific for each connected client that is passed out on each response and consumed for each client request. TODO: Specify the data type of the token and length
  • d — arbitrary data in a json object that the command for this version should know how to execute.
@StefanWallin
StefanWallin / menu.html.erb
Created December 9, 2015 14:53
Recursive cells — is it possible?
<%= render_cell(:menu, :show, { contents: @menu_content }) %>
@StefanWallin
StefanWallin / nodejs-centos5.sh
Created August 19, 2011 11:11
nodejs installed on centos 5
[stefan@dev36 src]$ rpm -ivh nodejs-0.4.9-1.1.x86_64.rpm
warning: nodejs-0.4.9-1.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID dfef6298
error: Failed dependencies:
libcares.so.2()(64bit) is needed by nodejs-0.4.9-1.1.x86_64
libev.so.4()(64bit) is needed by nodejs-0.4.9-1.1.x86_64
libv8.so.3()(64bit) is needed by nodejs-0.4.9-1.1.x86_64
libv8_g.so.3()(64bit) is needed by nodejs-0.4.9-1.1.x86_64
[stefan@dev36 lib]$ sudo yum install c-ares
[stefan@dev36 lib]$ sudo yum install --nogpgcheck libev

Post Upgrade to El Capitan, with Homebrew & Ruby

... and Xcode and Java, etc.

Prepare

If you don't already have homebrew installed, do that first, so you don't have to deal with SIP issues. Install all Software Updates available in the Apple Menu, up to and including El Capitan.

Hardware

@StefanWallin
StefanWallin / plugin_name.js
Created October 8, 2015 10:27
Javascript jQuery namespaced functionality nugget
document.mittmedia = document.mittmedia || {};
(function(object, jQuery, ...dependencies...){
object.plugin_name = {
elements: {
},
init: function(){
this.gatherElements()
this.bindEventHandlers()
},
gatherElements: function(){

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For less, I'm using the ruby version because this is what they suggest on the website. The javascript version may be different.

Variables

@StefanWallin
StefanWallin / output.sh
Created August 19, 2011 11:21
nodejs installed and then compile on centos 5
[stefan@dev36 node]$ ./configure && make
Checking for program g++ or c++ : /usr/lib64/ccache/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for program gcc or cc : /usr/lib64/ccache/gcc
Checking for gcc : ok
Checking for library dl : yes
Checking for openssl : yes
class AddFlagsToHuman < ActiveRecord::Migration
def change
# Add the flags
add_column :humen, :signed_up, :boolean, default: false
add_column :humen, :welcome_email_sent, :boolean, default: false
# Set the flags values
reversible do |dir|
dir.up do
Humen.all.select(&:signed_up?).each do |human|
@StefanWallin
StefanWallin / mediaquery scss
Created June 14, 2015 19:58
Could this be done better? The media query is sooo out of place...
#teamroster {
overflow: hidden;
@media (min-width: 600px) {
.team-display {
float: left;
overflow: hidden;
width: 30.3333333%;
margin-right: 1.5%;
min-width: 30%;

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying