Skip to content

Instantly share code, notes, and snippets.

View ruslanashaari's full-sized avatar
🎯
Focusing

Ruslan Ashaari ruslanashaari

🎯
Focusing
  • Tata Consultancy Services
  • Kuala Lumpur
View GitHub Profile
@ruslanashaari
ruslanashaari / adminer.css
Created April 12, 2019 18:04 — forked from robertopc/adminer.css
Adminer Black Custom Theme
/** theme "easy on the eyes" for Adminer by p.galkaev@miraidenshi-tech.jp */
/** customized by RobertoPC in https://gist.github.com/robertopc/bf2edac131bbaf789343fa9ce3ceb2e4 **/
@import url(//fonts.googleapis.com/css?family=Roboto+Mono:400,900);
/* for font awesome */
*:not(.fa) {
font-family: 'Roboto Mono', sans-serif;
}
@ruslanashaari
ruslanashaari / ValetSwitchPHP.md
Created May 12, 2018 12:12 — forked from bgarrant/ValetSwitchPHP.md
How to Switch PHP Version in Laravel Valet between PHP 7.1 and PHP 5.6

Valet switch PHP version with these commands

Install PHP 5.6 and switch Valet to PHP 5.6

valet stop
brew unlink php71
brew install php56
brew install php56-mcrypt
brew link php56
valet start
@ruslanashaari
ruslanashaari / AreaCalculator.php
Last active October 4, 2017 15:37
Using is_a or instanceof 1. is_a being a function takes an object as parameter 1, and a string (variable, constant, or literal) as parameter 2. So; ```is_a($object, $string); //only way to call it``` 2. instanceof takes an object as parameter 1, and can take a class name (variable), object instance (variable), or class identifier (class name wri…
<?php
class AreaCalculator {
public function calculate($shapes)
{
//using is_a
if(is_a($shape, 'Square') //
{
<?php
$results = $this->resource->get(array('id','column1','column2','column3', 'etc'));
$fileName = 'my-export-'.Carbon::now()->timestamp;
$export = $this->excel->create($fileName, function($excel) use ($results) {
$excel->setTitle('Our new awesome title')
->setCreator('Maatwebsite')
->setCompany('Maatwebsite')
/*
This snippet is esssentially the same as being in the Twitter longer tweets test, for tweetdeck.
The Tweet length counter is fixed by tricking TweetDeck into counting up to 140 characters, twice, so you'll see 140
instead of 280 in the counter but going over 140 will give you another set of 140 charactrs.
*/
TD.services.TwitterClient.prototype.makeTwitterCall=function(b,e,f,g,c,d,h){c=c||function(){};d=d||function(){};b=this.request(b,{method:f,params:Object.assign(e,{weighted_character_count:!0}),processor:g,feedType:h});return b.addCallbacks(function(a){c(a.data)},function(a){d(a.req,"",a.msg,a.req.errors)}),b};
twttrTxt=Object.assign({},twttr.txt,{isInvalidTweet:function(){return!1},getTweetLength:function(x){return x=twttr.txt.getTweetLength.apply(this,arguments),x<140||x/140>2?x:x%140}});
@ruslanashaari
ruslanashaari / Reply.php
Last active October 3, 2017 18:45
any custom property that we want to append to any json/array representative from model. 1. add a public function getter using a camel case of the column to define the column value 2. set a protected array of the column p/s: laravel 5.1 above doc ref: https://laravel.com/docs/5.1/eloquent-serialization#appending-values-to-json s/o ref: https://st…
//in model Reply.php
protected $appends = ['favoritesCount'];
//so when data are being called from this model, element favoritesCount are included in the json/array
//another example from stackoverflow
@ruslanashaari
ruslanashaari / invoke.php
Last active September 23, 2017 02:46
call route without function with invoke (only for single function in controller)
<?php
//in controller if there is only a single function
public function __invoke(){
}
//in routes just call controller name without @(function name)
@ruslanashaari
ruslanashaari / isogram.php
Created September 10, 2017 15:01
Determine if a word or phrase is an isogram.
<?php
function isIsogram($phrase){
$array_phrase = str_split(strtolower(preg_replace('/[\s-äöü]/', '', $phrase)));
return count($array_phrase) == count(array_unique($array_phrase));
}
@ruslanashaari
ruslanashaari / 0_reuse_code.js
Created September 8, 2017 00:30
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ruslanashaari
ruslanashaari / pangram.php
Created September 8, 2017 00:28
Check if a string is a pangram or not #exercism
<?php
function isPangram($param) {
$sentences = strtolower(trim($param));
$letters = str_split("thequickbrownfoxjumpsoverthelazydog");
foreach ($letters as $letter) {
if (!strstr($sentences, $letter))
return false;
}
return true;