Skip to content

Instantly share code, notes, and snippets.

View apaatsio's full-sized avatar

Antti Ahti apaatsio

View GitHub Profile
@apaatsio
apaatsio / xfce4-dev-setup.sh
Last active December 17, 2015 11:39
Setup script for Xfce4 build dependencies on Ubuntu. With these you can build at least xfwm4, xfce4-appfinder, xfce4-panel, and xfce4-terminal.
#!/bin/sh
apt-get -y install gcc gtk-doc-tools libexo-1-dev libgarcon-1-0-dev libglib-2.0-dev libvte-dev libwnck-dev libxfce4ui-1-dev libxfce4util-dev xfce4-dev-tools xserver-xorg-dev
@apaatsio
apaatsio / highlight_dom_elements.js
Created January 31, 2013 14:25
Highlight all DOM elements with a color so it's easy see an overview of the elements at quick glance
var elements = document.querySelectorAll('*');
Array.prototype.slice.call(elements).forEach(function (element) {
var rgba = [Math.floor(Math.random()*256), Math.floor(Math.random()*256), Math.floor(Math.random()*256), 0.1];
element.style.background = 'none';
element.style.backgroundColor = 'rgba(' + rgba.join(',') + ')';
});
@apaatsio
apaatsio / password_generator.coffee
Last active October 11, 2015 00:38
password generating function
generatePassword = (length) ->
# similar looking characters have been removed (e.g. letter l(L) and number 1)
allowedChars = "acdefghjkmnpqrstuvwxyzCDEFGHJKLMNPQRTUVWXY3679-+?@"
password = ""
for [1..length]
password += allowedChars[Math.floor(Math.random() * allowedChars.length)]
password
@apaatsio
apaatsio / plugin.js
Created April 18, 2012 08:36
how to unit test internal functions in jquery plugin?
// Define global Test object. You can leave this out in production.
Test = Test || {};
(function($) {
var someHelperFunction = function(s, d) {
return s*d;
}
var someOtherHelperFunction = function(s) {
return s*2;
@apaatsio
apaatsio / photo.rb
Created August 1, 2011 10:02
S3 config for Paperclip
class Photo < ActiveRecord::Base
has_attached_file :image,
:styles => {
:thumb => '100x100',
:large => '640x480',
},
:storage => :s3,
:s3_credentials => "#{::Rails.root.to_s}/config/s3.yml",
:path => ':attachment/:id/:style.:extension',
:bucket => 'my-bucket',