Skip to content

Instantly share code, notes, and snippets.

View demental's full-sized avatar

Arnaud Sellenet demental

  • enerfip.eu
  • france
View GitHub Profile
= t('people.list.on_twitter', :link => link_to("@#{list_item.twitter}", "https://twitter.com/#{list_item.twitter}")).html_safe
@demental
demental / gist:1227592
Created September 19, 2011 20:57
Textmate YAML check syntax command
ruby -ryaml -e 'begin
YAML.load(STDIN.read)
p "Syntax OK"
rescue
print "ERROR: ",$!, "\n"
end
'
@demental
demental / Client.php
Created March 15, 2012 16:39
hooks on linksFormTables
<?php
// office/lib/hooks/Client.php
class Client_hook
{
public static function alterLinkFromTables($links,$do)
{
require_once 'lib/CustomUtils.php';
class Wmit::Event < ActiveRecord::Base
end
@demental
demental / ba_app_first_or_array.rb
Created October 29, 2012 11:04
respond_to? VS kind_of?
def with_respond(object)
object.respond_to?(:first)
end
def with_array(object)
object.kind_of? Array
end
class Aclass
//
using('#searchMessage').expect(binding('query')).toBe('nexus');
// VS
using('#searchMessage').expect(binding('query').toBe('nexus')); // => WRONG, but test skipped
class Foo
METHODE_NAMES = ['problems', 'maintenances', 'journeys']
class << self
def get_var(name, hsh)
ApiRequest.new(params: {account_id: hsh[:email], vin: hsh[:vin]},
url: "vehicles/#{hsh[:vin]}/#{name}", verb: "get").get
end
METHODE_NAMES.each do name
@demental
demental / vsftpd-pid.sh
Created April 16, 2013 07:30
vsftp init script with pidfile. Handy for monit
#!/bin/sh -e
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.
set -e
INITSCRIPT="$(basename "$0")"
JOB="vsftpd"
@demental
demental / if_with_assign.rb
Created April 17, 2013 08:24
Beware that inline statements in ruby uses Proc
class MyClass
class << self
def with_inline_statement
result = nil
response = result.first if(result = item).exists?
response
end
def with_multiline_statement
if (result = item).exists?
response = result.first
= simple_form_for resource, as: resource_name, url: registration_path(resource_name), html: { class: 'form-horizontal'} do |f|
%fieldset
= f.input :email
= f.input :password, label: t('users.choose_password')
= f.input :password_confirmation
= f.input :terms_of_service, as: :boolean, wrapper: :fullwidth_checkbox
.form-actions
= f.button :submit, t("devise.shared.sign_up"), class: 'btn btn-primary btn-large'