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
# update checks validation, updates the value on DB, returns the object | |
# Updating one record: | |
Person.update(15, :user_name => 'Samuel', :group => 'expert') | |
# Updating multiple records: | |
people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy" } } | |
Person.update(people.keys, people.values) | |
# Or if you already got an object | |
person = Person.find(15) |
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
# inside of Gemfile | |
ruby "2.1.0", engine: "rbx", engine_version: "2.2.7" |
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 Bird { | |
public function sing () { | |
echo 'Tweet'; | |
} | |
} | |
$bird = new Bird(); | |
$bird->sing(); |
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
<?php | |
$_FILES['name-of-the-field']['tmp_name']; | |
$_FILES['name-of-the-field']['name']; | |
$_FILES['name-of-the-field']['type']; // "image/jpeg", "image/png", "image/gif" | |
$_FILES['name-of-the-field']['size']; | |
$_FILES['name-of-the-field']['error']; // returns 0 if there's no error | |
?> |
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
// 'angular way' to create a controller (prevent minification error) | |
// source: http://weblogs.asp.net/dwahlin/archive/2013/12/01/structuring-angularjs-code.aspx | |
angular.module('moduleName').controller('MainController', ['$scope', function($scope) { | |
//Code goes here | |
}]); |
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
<?php | |
header("Location: file_name.php"); // redirect to file_name.php | |
?> |
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
// load external data | |
$('input.typeahead-devs').typeahead({ | |
name: 'accounts', | |
prefetch: 'countries.json' | |
}); |
NewerOlder