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 / gist:dc15cf0b35e41726e9973d653b7bb25d
Created August 16, 2017 16:48
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@ruslanashaari
ruslanashaari / plivo_curl.php
Created August 30, 2017 10:20 — forked from tsudot/plivo_curl.php
Send an SMS using curl through Plivo.
<?php
# Plivo AUTH ID
$AUTH_ID = '';
# Plivo AUTH TOKEN
$AUTH_TOKEN = '';
# SMS sender ID.
$src = '';
@ruslanashaari
ruslanashaari / raindrops.php
Created September 8, 2017 00:17
Convert a number to a string, the contents of which depend on the number's factors. #exercism
<?php
function raindrops($drops) {
$output = '';
if ($drops%3 == 0) {
$output .= "Pling";
}
if ($drops%5 == 0) {
@ruslanashaari
ruslanashaari / rna-transcription.php
Created September 8, 2017 00:27
Given a DNA strand, return its RNA complement (per RNA transcription) #exercism
<?php
function toRna($nucleotides) {
$dnaToRna = [
"G" => "C",
"C" => "G",
"T" => "A",
"A" => "U"
];
return strtr(strtoupper($nucleotides), $dnaToRna);
@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;
@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 / 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 / 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)
/*
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}});
<?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')