An introduction to curl
using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
# Ways to execute a shell script in Ruby | |
# Example Script - Joseph Pecoraro | |
cmd = "echo 'hi'" # Sample string that can be used | |
# 1. Kernel#` - commonly called backticks - `cmd` | |
# This is like many other languages, including bash, PHP, and Perl | |
# Synchronous (blocking) | |
# Returns the output of the shell command | |
# Docs: http://ruby-doc.org/core/classes/Kernel.html#M001111 |
############################################################################# | |
# Class: Vash (Ruby Volatile Hash) | |
# Hash that returns values only for a short time. This is useful as a cache | |
# where I/O is involved. The primary goal of this object is to reduce I/O | |
# access and due to the nature of I/O being slower then memory, you should also | |
# see a gain in quicker response times. | |
# | |
# For example, if Person.first found the first person from the database & cache | |
# was an instance of Vash then the following would only contact the database for | |
# the first iteration: |
require 'my-sinatra-app' | |
require 'sinatra/activerecord/rake' | |
desc "run irb console" | |
task :console, :environment do |t, args| | |
ENV['RACK_ENV'] = args[:environment] || 'development' | |
exec "irb -r irb/completion -r my-sinatra-app" | |
end |
require "test/unit" | |
class Array | |
def fifo | |
verbrauch = inject(0) {|sum, el| sum+=el.abs if el < 0; sum } | |
res = select{|el| el > 0}.inject([]) do |result, el| | |
if el > verbrauch | |
result << (el - verbrauch) | |
verbrauch = 0 | |
else |
God.watch do |w| | |
w.name = "mysqld" | |
w.interval = 30.seconds # default | |
w.start = "service mysql start" | |
w.stop = "service mysql stop" | |
w.restart = "service mysql restart" | |
w.start_grace = 20.seconds | |
w.restart_grace = 20.seconds | |
w.pid_file = "/var/lib/mysql/hostname.pid" | |
The MIT License (MIT) | |
Copyright (c) 2015 Oleg Ivanov http://github.com/morhekil | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
namespace :admin do | |
desc "creates and admin user" | |
task :create => :environment do | |
line = HighLine.new # a command line lib that uses erb? Bizarre. | |
line.say "<%= color('Creating a new administrative user', BOLD) %>" | |
email = line.ask("Email: ") | |
pass = line.ask("Password: " ) { |q| q.echo = "*" } | |
admin = Admin.new(:email => email, :password => pass) |
An introduction to curl
using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
build/ |
#!/bin/bash -ex | |
# Paste this into ssh | |
# curl -sL https://gist.github.com/andsens/2913223/raw/bootstrap_homeshick.sh | tar -xzO | /bin/bash -ex | |
# When forking, you can get the URL from the raw (<>) button. | |
### Set some command variables depending on whether we are root or not ### | |
# This assumes you use a debian derivate, replace with yum, pacman etc. | |
aptget='sudo apt-get' | |
chsh='sudo chsh' |