This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
unamestr=`uname` | |
platform_path='unknown' | |
if [[ "$unamestr" == "Linux" ]]; then | |
platform_path='/usr/bin' | |
if [[ $UID != 0 ]]; then | |
echo "Please run this script with sudo:" | |
echo "sudo $0 $*" | |
exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Let's say you have a collection of users you want to email once a week. | |
# Now using Sidekiq, it's easy to move this off the main thread, so that you're not blocking | |
# incoming requests to the Rails application. | |
# | |
#Chances are you have a worker that looks like the EmailUsersWorker below. | |
# | |
class EmailUsersWorker | |
include Sidekiq::Worker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
instances = Model.all | |
# If I try to perform this on all the instances, all return true but the changes are not persisted. | |
instances.each do |instance| | |
desc = instance.description | |
desc.gsub!(/some\swords/, '') | |
instance.update(:description => desc) # doesn't work | |
instance.description = desc | |
instance.save # doesn't work and returns true. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RootScreen < ProMotion::Screen | |
title "Bienvenue" | |
def will_appear | |
UIBarButtonItem.configureFlatButtonsWithColor([89, 91, 91].uicolor, highlightedColor: [64, 65, 65].uicolor, cornerRadius: 2.0) | |
set_navigation_appearnce! | |
set_attributes self.view, { | |
backgroundColor: [222, 226, 225].uicolor | |
} | |
@label ||= UILabel.alloc.initWithFrame(CGRectZero) | |
@label.text = "Application" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Notes: | |
# | |
# FlatUIKit: https://github.com/Grouper/FlatUIKit | |
# | |
# Their Example: | |
# [UIBarButtonItem configureFlatButtonsWithColor:[UIColor peterRiverColor] | |
# highlightedColor:[UIColor belizeHoleColor] | |
# cornerRadius:3]; | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[UIBarButtonItem configureFlatButtonsWithColor:[UIColor peterRiverColor] | |
highlightedColor:[UIColor belizeHoleColor] | |
cornerRadius:3]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Model < ActiveRecord::Base | |
attr_accessor :was_new_record | |
def was_new_record? | |
@was_new_record == true ? true : false | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'watir-webdriver' | |
capabilities = Selenium::WebDriver::Remote::Capabilities.phantomjs("phantomjs.page.settings.userAgent" => "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36") | |
driver = Selenium::WebDriver.for :phantomjs, :desired_capabilities => capabilities | |
browser = ::Watir::Browser.new driver | |
# Quick test to make sure it's set | |
browser.goto 'http://www.useragentstring.com/' | |
browser.textarea(:id => "uas_textfeld").value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'vips' | |
class Photo < ActiveRecord::Base | |
# Include the VIPS moduel in model so we have access to the `Image` class | |
include VIPS | |
# Basic attributes | |
attr_accessible :image, :image_cache, :crop_x, :crop_y, :crop_w, :crop_h | |
# mount Carrierwave | |
mount_uploader :image, PhotoUploader | |
# Call the minimum_dimensions method on validation | |
validate :minimum_dimensions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
# -- | |
# Copyright (C) 2008-2011 10gen Inc. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 |