Skip to content

Instantly share code, notes, and snippets.

View schaary's full-sized avatar

Michael Schaarschmidt schaary

  • Halle (Saale), Germany
View GitHub Profile
@schaary
schaary / gist:f036db10dc2cddaa7577
Created April 7, 2015 08:07
Check the installed ubuntu version
lsb_release -a
@schaary
schaary / new_server_packages.md
Last active August 29, 2015 14:18
Pakete auf einem neuen Server
  • git-core (ppa:git-core/ppa)
  • ag (silversearcher-ag)
  • neovim (ppa:neovim-ppa/unstable)
@schaary
schaary / index.md
Last active August 29, 2015 14:11 — forked from rstacruz/index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@schaary
schaary / Gemfile
Created September 26, 2014 09:35
Basic Gemfile at the Beginning of a Project
source 'https://rubygems.org'
gem 'dotenv-rails'
gem 'rails', '4.1.6'
gem 'pg'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
# gem 'therubyracer', platforms: :ruby
@schaary
schaary / sha1_revert.rb
Created July 15, 2014 12:13
sha1 hin und wieder zurück
# Quelle: http://anthonylewis.com/2011/02/09/to-hex-and-back-with-ruby/
Base64.decode64('ZNgCF5auf9KN/PzwpUaxKyvLAtU=').each_byte.map{ |b| b.to_s(16) }.join
@schaary
schaary / push_studip_user_to_ilias_ea.rb
Created July 15, 2014 07:30
push studip user to ilias_ea
#!/usr/bin/env ruby
# encoding: utf-8
require 'net/ldap'
require 'awesome_print'
require 'csv'
def fetch_from_ldap uid
connect_ldap
@schaary
schaary / todo.md
Created April 29, 2014 13:44
ToDo Test
  • hello world
  • hello World
  • hallo world
  • Hello Welt
@schaary
schaary / ldapbind.rb
Created April 11, 2014 08:43
ldap_bind with net-ldap
require 'net/ldap'
ldap = Net::LDAP.new
ldap.host = your_server_ip_address
ldap.port = 389
ldap.auth "joe_user", "opensesame"
if ldap.bind
# authentication succeeded
else
# authentication failed
@schaary
schaary / ldapsearch.rb
Last active August 29, 2015 13:58
shows an example ldapsearch call with net/ldap gem, when you have the dn of the entry
basedn = "uid=foo,ou=bar,c=baz"
attrs = ["mail", "cn", "sn", "objectclass"]
ldap.search(:base => basedn, :attributes => attrs) do |entry|
puts "DN: #{entry.dn}"
entry.each do |attr, values|
puts "#{attr}:"
values.each do |value|
puts "#{value}"
end
end
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')