Skip to content

Instantly share code, notes, and snippets.

@adnils
adnils / irccloud-solarized.css
Created October 14, 2014 11:11
IRCCloud Solarized
td.nickcell a.nick,
td.inputcell textarea,
div.log div.messageRow,
div.log div.me a.user {
/* font-family: "Consolas", "Monaco", "Source Code Pro", "Droid Sans Mono", monospace !important; */
font-size: 14px !important;
}
body,
.mainContainer,
@adnils
adnils / README.md
Last active August 29, 2015 14:20 — forked from joakimk/README.md

This runs a build for a small elixir (phoenix) project in about 40 seconds by caching as much of the compiled files as possible. It's not been run for very long so I don't know if it caches too much or of there is any other issues.

It should be generic enough to work on any elixir app using mix.

@adnils
adnils / server.ex
Last active August 11, 2020 16:37
Elixir TCP echo server
defmodule Echo.Server do
def start(port) do
tcp_options = [:binary, {:packet, 0}, {:active, false}]
{:ok, socket} = :gen_tcp.listen(port, tcp_options)
listen(socket)
end
defp listen(socket) do
{:ok, conn} = :gen_tcp.accept(socket)
spawn(fn -> recv(conn) end)
@adnils
adnils / nginx.conf
Last active August 29, 2015 14:24 — forked from plentz/nginx.conf
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@adnils
adnils / vim-highlight
Last active August 29, 2015 14:25
highlight occurrences of word under cursor on spacebar
let g:highlighting = 0
function! Highlighting()
if g:highlighting == 1 && @/ =~ '^\\<'.expand('<cword>').'\\>$'
let g:highlighting = 0
return ":silent nohlsearch\<CR>"
endif
let @/ = '\<'.expand('<cword>').'\>'
let g:highlighting = 1
return ":silent set hlsearch\<CR>"
endfunction
def index(conn, %{"event" => "true"}) do
conn = conn
|> put_resp_content_type("text/event-stream")
|> send_chunked(200)
{:ok, conn} = chunk(conn, ["data: ", JSON.encode!(Thermostat.Data.get()), "\n\n"])
Phoenix.Topic.subscribe self, "data"
data_updated(conn)
end
defp data_updated(conn) do
@adnils
adnils / preprocessor_fun.h
Last active August 29, 2015 14:27 — forked from aras-p/preprocessor_fun.h
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@adnils
adnils / _ff-addon-snippet-CF_QueryWorkspaceLockedInterval.js
Created December 2, 2015 16:46 — forked from Noitidart/_ff-addon-snippet-CF_QueryWorkspaceLockedInterval.js
_ff-addon-snippet-CF_QueryWorkspaceLockedInterval - Every one second it checks if workstaiton is locked. It looks like as soon as screensaver turns on, even if the require password delay is not "immedietly" the CGSSessionScreenIsLocked property is 1/true.(Mac OS X) (jsctypes)
if (typeof myint == 'undefined') {
var myint = null;
}
function doit(){
if (myint === null) {
myint = setInterval(function() {
Cu.import('resource://gre/modules/ctypes.jsm');
var lib = {
CoreGraphics: '/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics',
CoreFoundation: '/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation'
@adnils
adnils / channel-example.swift
Created December 4, 2015 12:34 — forked from kainosnoema/channel-example.swift
Golang-like concurrency semantics in Swift
import Foundation
go(println("in a thread"))
// buffered channel
var c = Chan(buffer:20)
// sending routing
go {
while(true) {
@adnils
adnils / nginxproxy.md
Created December 18, 2015 10:06 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers