Skip to content

Instantly share code, notes, and snippets.

View KamilLelonek's full-sized avatar
🏋️‍♂️
Do you even lift?

Kamil Lelonek KamilLelonek

🏋️‍♂️
Do you even lift?
View GitHub Profile
@KamilLelonek
KamilLelonek / deploy.rb
Created July 14, 2014 10:39
Upstart deployment
namespace :deploy do
after :publishing, :restart do
on roles(:app) do
within release_path do
execute :sudo, "cp -f #{release_path}/my_config.conf /etc/init/"
execute :sudo, 'initctl restart my_service'
end
end
end
end
@KamilLelonek
KamilLelonek / osx.sh
Created July 18, 2014 19:54
dot-files
#!/bin/bash
echo "Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)"
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
echo "Enable subpixel font rendering on non-Apple LCDs"
defaults write NSGlobalDomain AppleFontSmoothing -int 2
echo "Enable the 2D Dock"
defaults write com.apple.dock no-glass -bool true
@KamilLelonek
KamilLelonek / weather.java
Last active July 20, 2016 11:15
Developing Android Apps at Udacity
Httpconnection connection = null;
BufferedReader reader = null;
String forecastJsonStr = null;
try {
URL url = new URL("http://api.openweathermap.org/data/2.5/forecast/daily?q=94043&mode=json&units=metric&cnt=7");
connection = (Httpconnection) url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
@KamilLelonek
KamilLelonek / config.coffeeenv
Last active August 29, 2015 14:05
Facebook OpenGraph metadata generator
(env) ->
if env.ENV is 'production'
{
API_ENDPOINT: ''
FACEBOOK_ID: ''
FACEBOOK_NAMESPACE: ''
FACEBOOK_OBJECT: ''
}
else
{
@KamilLelonek
KamilLelonek / config.ru
Created September 5, 2014 22:53
Serving static files from Rack
root = 'public'
use Rack::Static,
urls: Dir["#{root}/*"].map { |file| file.sub(root, '')},
root: root,
index: 'index.html',
header_rules: [[:all, { 'Cache-Control' => 'public, max-age=3600' }]]
run -> env {
[
@KamilLelonek
KamilLelonek / create-cookbook.rb
Last active August 29, 2015 14:07
Cookbook CLI creator
#!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
class CookbookCreator
COMPANY_NAME = 'COMPANY_NAME'
EMAIL = '[email protected]'
COOKBOOK_NAME = 'COOKBOOK_NAME'
class << self
@KamilLelonek
KamilLelonek / is_prime.scala
Created October 24, 2014 21:23
Scala prime numbers
def isPrime(number: Int) = (2 until number) forall (divider => number % divider != 0)
@KamilLelonek
KamilLelonek / block_middle_click.js
Created October 24, 2014 21:32
Block middle click in browser
document.querySelector("a").addEventListener("mousedown", function(e) {
if (e.which === 2) {
this.style.pointerEvents = "none";
}
});
document.body.addEventListener("mouseup", function(e) {
if (e.which === 2) {
document.querySelector("a").style.pointerEvents = "";
}
@KamilLelonek
KamilLelonek / hipster.js
Created October 24, 2014 21:33
Hipster JavaScript usages
// Boring
if (success) {
obj.start();
} else {
obj.stop();
}
// Hipster-fun
var method = (success ? 'start' : 'stop');
obj[method]();
@KamilLelonek
KamilLelonek / extensions.module.coffee
Last active August 29, 2015 14:08
Fake cacheFactory for AngularJS
Extensions = angular.module 'MyApplication.ExtensionsModule', []
# ...
Extensions.factory '$templateCache', [
'$cacheFactory', '$http', '$injector', 'SecurityConstants',
($cacheFactory, $http, $injector, SecurityConstants) ->
cache = $cacheFactory('templates')
promise = undefined