You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';This is quite common and very helpful. Another option is to do:
name || (name = 'joe');You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';This is quite common and very helpful. Another option is to do:
name || (name = 'joe');| <?php | |
| /** | |
| * Kelas untuk memanipulasi data yang berkaitan dengan rupiah. | |
| * | |
| * Catatan: Saya lupa darimana contoh fungsi terbilang awalnya! | |
| * | |
| * @version 0.0.1 | |
| * @author Anggiajuang Patria <[email protected]> | |
| * @copyright (c) 2009-2010 http://www.segellabs.com/ | |
| * @license http://www.gnu.org/licenses/gpl-3.0.txt |
| HTTP status code symbols for Rails | |
| Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings. | |
| Status Code Symbol | |
| 1xx Informational | |
| 100 :continue | |
| 101 :switching_protocols | |
| 102 :processing |
| package main | |
| import ( | |
| "fmt" | |
| "labix.org/v2/mgo" | |
| "labix.org/v2/mgo/bson" | |
| "time" | |
| ) | |
| type Person struct { |
| Array.prototype.shuffle = function () { | |
| var i, j, tempi, tempj; | |
| i = this.length; | |
| if ( i === 0 ) { | |
| return false; | |
| } | |
| while ( --i ) { | |
| j = Math.floor( Math.random() * ( i + 1 ) ); | |
| tempi = this[i]; |
| /* | |
| This snippet is an example of backpressure implementation in Go. | |
| It doesn't run in Go Playground, because it starts an HTTP Server. | |
| The example starts an HTTP server and sends multiple requests to it. The server starts denying | |
| requests by replying an "X" (i.e. a 502) when its buffered channel reaches capacity. | |
| This is not the same as rate-limiting; you might be interested in https://github.com/juju/ratelimit | |
| or https://godoc.org/golang.org/x/time/rate. |
| /* | |
| Parallel processing with ordered output in Go | |
| (you can use this pattern by importing https://github.com/MarianoGappa/parseq) | |
| This example implementation is useful when the following 3 conditions are true: | |
| 1) the rate of input is higher than the rate of output on the system (i.e. it queues up) | |
| 2) the processing of input can be parallelised, and overall throughput increases by doing so | |
| 3) the order of output of the system needs to respect order of input | |
| - if 1 is false, KISS! |
| require 'openssl' | |
| class String | |
| def encrypt(key) | |
| cipher = OpenSSL::Cipher::Cipher.new('DES-EDE3-CBC').encrypt | |
| cipher.key = Digest::SHA1.hexdigest key | |
| s = cipher.update(self) + cipher.final | |
| s.unpack('H*')[0].upcase | |
| end |
#Laravel 5 Simple ACL manager
Protect your routes with user roles. Simply add a 'role_id' to the User model, install the roles table and seed if you need some example roles to get going.
If the user has a 'Root' role, then they can perform any actions.
Simply copy the files across into the appropriate directories, and register the middleware in App\Http\Kernel.php
http://guides.rubyonrails.org/migrations.html