Skip to content

Instantly share code, notes, and snippets.

@moret
moret / server.rb
Created October 18, 2018 13:50
ruby socket read timeout server.rb
#server.rb
require 'socket'
delay = 5
server = TCPServer.new 2000
loop do
client = server.accept
puts "#{Time.now} > Client arrived. Sleeping for #{delay}s."
@moret
moret / client-socket-options.rb
Created October 18, 2018 13:49
ruby socket read timeout client-socket-options.rb
#client-socket-options.rb
require 'socket'
host = '127.0.0.1'
port = 2000
timeout = 2
timeout_val = [ timeout, 0 ].pack("l_2")
s = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
@moret
moret / client.c
Last active October 18, 2018 13:48
ruby socket read timeout client.c
//client.c
#include <stdio.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
char *host = "127.0.0.1";
@moret
moret / ordering.js
Created November 5, 2015 00:28
Sequelize ordering by attributes with non-matching fieldnames
import _ from 'underscore';
import Promise from 'bluebird';
import {
GraphQLInt,
GraphQLList,
GraphQLObjectType,
GraphQLSchema,
GraphQLString
} from 'graphql';
import {
@moret
moret / n-to-m.js
Last active May 18, 2017 01:17
N to M GraphQL Sequelize Question
import _ from 'underscore';
import Promise from 'bluebird';
import {
GraphQLInt,
GraphQLList,
GraphQLObjectType,
GraphQLSchema,
GraphQLString
} from 'graphql';
import {
<html>
<head>
<script type='text/javascript' src='http://cdn.clappr.io/latest/clappr.min.js'></script>
</head>
<body>
<div id='player'></div>
<div id='status'>loading...</div>
<script>
var updateStatus = function(status) {document.getElementById('status').innerHTML = status;};
var player = new Clappr.Player({
@moret
moret / pr.md
Last active August 29, 2015 14:27 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@moret
moret / haxe-openfl.sh
Last active June 6, 2021 17:30
Install Haxe using Brew and set the haxelib path
# Install Haxe using Brew and set the haxelib path
brew install haxe
haxelib setup /usr/local/Cellar/haxe/lib
# Install lime
haxelib install lime
# Install lime tools
haxelib install format
haxelib install svg
body {
background-color: #fdf6e3;
color: #657b83;
font-size: 14px;
white-space: pre;
font-family: "Menlo", monospace;
}
.property {
font-weight: bold;
@moret
moret / Solarized Light and Dark.dvtcolortheme
Created June 6, 2014 18:46
~/Library/Developer/Xcode/UserData/FontAndColorThemes
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.727544 0.222335 0 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Menlo-Bold - 14.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>0.443313 0.509062 0.518274 1</string>