Skip to content

Instantly share code, notes, and snippets.

Michał Siwek skycocker

Block or report user

Report or block skycocker

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
skycocker / image_uploadable.rb
Last active Mar 3, 2020
Uploading images to a Rails API using Paperclip (via either base64 string-encoded image or a public HTTP image URL)
View image_uploadable.rb
module ImageUploadable
extend ActiveSupport::Concern
def set_image_by_params_for(model, params)
image_uri = params[:image_uri]
image_base64 = params[:image_base64]
set_image_from_uri_for(model, image_uri) if image_uri.present?
skycocker / nginx-noscript.conf
Created Aug 10, 2018
Fixed version of the default nginx/apache-noscript.conf file, considering you might have something else than simply a filename in the matching string
View nginx-noscript.conf
failregex = ^<HOST> -.*GET(?!.*\?.*\=) .*(\.php|\.asp|\.exe|\.pl|\.cgi|\.scgi)
ignoreregex =
skycocker / passwords_controller.rb
Created Jul 2, 2018
Add Location header clone for Alamofire + devise_token_auth password reset flow
View passwords_controller.rb
class Auth::PasswordsController < DeviseTokenAuth::PasswordsController
def edit
# Alamofire tends to ignore Location header in .allHeaderFields, blindly following its contents instead
# so we add a new header with the same value
# in order to parse it in mobile app
response.headers['Alamofire-Location'] = response.headers['Location']
skycocker / Gemfile
Last active Jan 14, 2020
Get basic user info from Google Oauth V2 api (since google is an extraordinary piece of shit when it comes to documenting their stuff) (or making admin consoles)
View Gemfile
gem 'google-api-client'
skycocker /
Last active Mar 13, 2020
Enable 1G swap space on ubuntu (or pretty much any other linux distro) - useful on Amazon/Digitalocean instances
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sudo sysctl vm.swappiness=10
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
sudo sysctl vm.vfs_cache_pressure=50
View the-basics.html
<div id="the-basics">
<input class="typeahead" type="text" placeholder="States of USA">
skycocker / gist:7074415
Last active Dec 26, 2015
View gist:7074415
{"level":"info","message":"process type is test_frontend","timestamp":"2013-10-20T19:48:37.935Z"}
{"date":"Sun Oct 20 2013 21:48:37 GMT+0200 (CEST)","process":{"pid":10301,"uid":1000,"gid":1000,"cwd":"/home/skycocker/Desktop/browserid","execPath":"/usr/local/bin/node","version":"v0.10.21","argv":["node","/home/skycocker/Desktop/browserid/scripts/test_frontend"],"memoryUsage":{"rss":18509824,"heapTotal":15453568,"heapUsed":7987892}},"os":{"loadavg":[1.8203125,1.7841796875,1.77001953125],"uptime":3959.078639706},"trace":[{"column":11,"file":"child_process.js","function":"errnoException","line":980,"method":null,"native":false},{"column":34,"file":"child_process.js","function":"Process.ChildProcess._handle.onexit","line":771,"method":"ChildProcess._handle.onexit","native":false}],"stack":["Error: spawn ENOENT"," at errnoException (child_process.js:980:11)"," at Process.ChildProcess._handle.onexit (child_process.js:771:34)"],"level":"error","message":"uncaughtException: spawn ENOENT","timestamp":"2013-10-20
skycocker / whistle_analyser.js
Created Oct 7, 2013
Whistle.js analyser snippet
View whistle_analyser.js
var frequencies = new Uint8Array(analyser.frequencyBinCount);
for(var i=25; i<=80; ++i) {
if(frequencies[i] > 250) document.dispatchEvent(whistleEvent);
skycocker / vim.rb
Created Sep 28, 2013
Chromebrew package file example
View vim.rb
require 'package' # include package class file
class Vim < Package # name the package and make it a Package class instance
version '7.4' # software version
source_url '' # software source tarball url
source_sha1 '601abf7cc2b5ab186f40d8790e542f86afca86b7' # source tarball sha1 sum
depends_on 'ncurses' # software dependencies
def # contains commands needed to build the software from source
You can’t perform that action at this time.