Skip to content

Instantly share code, notes, and snippets.

View sunkibaek's full-sized avatar
💻
Coding

Sunki Baek sunkibaek

💻
Coding
  • Calgary
View GitHub Profile
# 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)
@sunkibaek
sunkibaek / Gemfile
Last active August 29, 2015 14:02
Use rubinius for Rails
# inside of Gemfile
ruby "2.1.0", engine: "rbx", engine_version: "2.2.7"
class Bird {
public function sing () {
echo 'Tweet';
}
}
$bird = new Bird();
$bird->sing();
<?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
?>
// '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
}]);
@sunkibaek
sunkibaek / php_functions.php
Last active December 30, 2015 09:39
PHP Sessions
<?php
header("Location: file_name.php"); // redirect to file_name.php
?>
// load external data
$('input.typeahead-devs').typeahead({
name: 'accounts',
prefetch: 'countries.json'
});