Skip to content

Instantly share code, notes, and snippets.

View jpalumickas's full-sized avatar
🚀
Hacking

Justas Palumickas jpalumickas

🚀
Hacking
View GitHub Profile
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Add rbenv to the path:
@jpalumickas
jpalumickas / osascript.rb
Last active July 1, 2021 11:36
osaScript Ruby examples
# === Terminal.app === #
# Open new tab in terminal.
exec("osascript -e 'tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down' > /dev/null 2>&1 ")
# Open directory
exec("osascript -e 'tell application \"Terminal\" to do script \"cd directory\" in selected tab of the front window' > /dev/null 2>&1 ")
# Open directory in new tab (this is better)
exec("osascript -e 'tell application \"Terminal\"' -e 'tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down' -e 'do script with command \"cd directory && clear\" in selected tab of the front window' -e 'end tell' > /dev/null 2>&1")
@jpalumickas
jpalumickas / devise.lt.yml
Last active December 16, 2015 05:09
Devise 2.2 translation.
lt:
devise:
confirmations:
confirmed: "Jūsų vartotojas sėkmingai patvirtintas. Dabar jūs esate prisijungę."
send_instructions: "Už keletos minučių el. paštu gausite instrukcijas, kaip patvirtinti savo vartotoją."
send_paranoid_instructions: "Jei jūsų el. pašto adresas yra mūsų duomenų bazėje, kelių minučių bėgyje gausite laišką su patvirtinimo instrukcijomis."
failure:
already_authenticated: "Jūs jau esate prisijungęs."
inactive: "Jūsų vartotojas dar nepatvirtintas."
invalid: "Neteisingas el. paštas arba slaptažodis."
#!/usr/bin/env ruby
# reviewed by Erik B on January 21 2012
# by @tapbot_paul
# Don't blame me if this nukes your metadata, formats your drive, kills your kids
# This script goes through any iCloud Matched songs in your iTunes library and tries to update the
# metadata from the iTunes Store
# Will run against selected tracks or if nothing selected entire library
# install the required gems with the following commands
# sudo gem install json --no-ri --no-rdoc
# sudo gem install rb-appscript --no-ri --no-rdoc
# app/controllers/users/password_controller.rb
class Users::PasswordsController < Devise::PasswordsController
def resource_params
params.require(:user).permit(:email, :password, :password_confirmation)
end
private :resource_params
end
# Automatically add mustaches to any images it can
#
#
module.exports = (robot) ->
robot.hear /^(https?:\/\/[^ #]+\.(?:png|jpg|jpeg))(?:[#]\.png)?$/i, (msg) ->
src = msg.match[1]
unless src.match(/^http:\/\/mustachify.me/)
msg.http("http://stacheable.herokuapp.com")
# Utility commands surrounding Hubot uptime.
spawn = require('child_process').spawn
module.exports = (robot) ->
robot.hear /hubot (who|where) are you\??/i, (msg) ->
msg.finish()
child = spawn('/bin/sh', ['-c', "echo I\\'m $LOGNAME@$(hostname):$(pwd) \\($(git rev-parse HEAD)\\)"])
child.stdout.on 'data', (data) ->
msg.send "#{data.toString().trim()} running node #{process.version} [version: #{robot.version}, pid: #{process.pid}, name: #{robot.name} ]"
def run!
pid = fork do
exec_pid = fork do
$0 = "heaven[#{Heaven.current_sha}] : executing deployment of #{application_name}"
out_file = File.new(log, "w")
STDIN.reopen("/dev/null")
STDOUT.reopen(out_file)
STDERR.reopen(out_file)
# http://unicorn.bogomips.org/SIGNALS.html
namespace :unicorn do
task :start, :roles => :app do
sudo "god start unicorn"
end
task :stop, :roles => :app do
sudo "god stop unicorn"
end