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
| // Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc | |
| // jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/ | |
| // author: Pawel Kozlowski | |
| var myApp = angular.module('myApp', []); | |
| //service style, probably the simplest one | |
| myApp.service('helloWorldFromService', function() { | |
| this.sayHello = function() { | |
| return "Hello, World!" |
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
| // taken from http://stackoverflow.com/a/2117523/3479739 | |
| 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | |
| var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); | |
| return v.toString(16); | |
| }); | |
| // example | |
| // 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);}); | |
| // "3bce4931-6c75-41ab-afe0-2ec108a30860" |
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 | |
| // ref : http://www.php.net/manual/en/datetime.diff.php | |
| // ref : http://www.php.net/manual/en/dateinterval.format.php | |
| $datetime1 = date_create('2009-10-11'); | |
| $datetime2 = date_create('2009-10-13'); | |
| $interval = date_diff($datetime1, $datetime2); | |
| echo $interval->format('%y years %m months %d days'); |
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
| function slug(string) { | |
| return string | |
| .toLowerCase() | |
| .replace(/[^a-zA-Z0-9]+/g,'-') | |
| .replace(/^-+/, '') // Trim - from start of text | |
| .replace(/-+$/, ''); // Trim - from end of text | |
| ; | |
| } |
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
| function getExtension(string) { | |
| return string.substr((~-string.lastIndexOf(".") >>> 0) + 2); | |
| } |
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
| var http = require('http'), | |
| fileJSON = require('./images.json'), | |
| fs = require('node-fs'), | |
| options, | |
| assets = fileJSON.imageArr; | |
| options = { | |
| host: 'url.com', | |
| port: 80, | |
| path: 'path/to/images' |
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
| @if ($errors->any()) | |
| <div class="alert alert-error alert-block"> | |
| <button type="button" class="close" data-dismiss="alert">×</button> | |
| <h4>Error</h4> | |
| Please check the form below for errors | |
| </div> | |
| @endif | |
| @if ($message = Session::get('success')) | |
| <div class="alert alert-success alert-block"> |
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 | |
| foreach (Cache::getMemory() as $cacheKey => $cacheValue) | |
| { | |
| if (strpos($cacheKey, 'mypackage') !== false) | |
| { | |
| Cache::forget($cacheKey); | |
| } | |
| } |
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 | |
| /********************************************************************************************* | |
| * Example usage (In view) | |
| * <div class="welcome"> | |
| <?php echo Form::open(array('route'=>'process','class'=>'form-horizontal'))?> | |
| <?php echo Form::textField('first_name')?> | |
| <?php echo Form::textField('last_name')?> | |
| <?php echo Form::emailField('email')?> | |
| <?php echo Form::passwordField('password')?> | |
| <?php echo Form::selectField('select_one', array('1'=>'abc', '2'=>'def'))?> |
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 | |
| $your_url='http://www.youtube.com/watch?var1=blabla#v=GvJehZx3eQ1$var2=bla'; | |
| function get_youtube_id_from_url($url){ | |
| if (stristr($url,'youtu.be/')) | |
| { preg_match('/(https:|http:|)(\/\/www\.|\/\/|)(.*?)\/(.{11})/i', $url, $final_ID); return $final_ID[4]; } | |
| else | |
| { preg_match('/(https:|http:|):(\/\/www\.|\/\/|)(.*?)\/(embed\/|watch\?v=|(.*?)&v=|v\/|e\/|.+\/|watch.*v=|)([a-z_A-Z0-9]{11})/i', $url, $IDD); return $IDD[6]; } | |
| } |