Skip to content

Instantly share code, notes, and snippets.

@rolldone
rolldone / 0_reuse_code.js
Last active August 29, 2015 14:25
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
@rolldone
rolldone / index.js
Last active May 14, 2018 22:57
Create simple app integrated redis with sub pub
var NRP = require("node-redis-pubsub");
var config = {
host: "localhost",
port: 6379, // Port of your locally running Redis server
scope: "prerender" // Use a scope to prevent two NRPs from sharing messages
};
var nrp = new NRP(config); // This is the NRP client
nrp.on("say hello", function(data) {
@rolldone
rolldone / index.html
Created May 15, 2018 01:45
get iframe dom using jquery
<iframe onload={()=>{
setTimeout(()=>{
// console.log(.html());
},1000);
$.when($('#framenya').contents().find('html')).then((dom)=>{
var waitForEl = function(selector, callback) {
if (dom.find(selector).length) {
setTimeout(function() {
callback();
}, 1000);
return response()->stream(function () use ($writer) {
$writer->save('php://output');
}, 200, [
'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'Content-Disposition' => 'attachment',
'filename' => 'file.xlsx',
]);
public function to_array(&$object = '')
{
// IF OBJECT, MAKE ARRAY
if (is_object($object)) {$object = (array) $object;}
// IF NOT ARRAY OR EMPTY ARRAY, RETURN = LEAVES SCALARS
if (!is_array($object) || empty($object)) {return;}
// FOR EACH ITEM, RECURSE VALUE
foreach ($object as &$Value) {$this->to_array($Value);}
@rolldone
rolldone / Error_PhpRedisConnection.txt
Last active June 27, 2019 04:23
Php redis error connectin
[2019-06-27 04:21:06] production.ERROR: read error on connection {"exception":"[object] (RedisException(code: 0): read error on connection at /home/akasa/artywiz/vendor/laravel/framework/src/Illuminate/Redis/Connections/PhpRedisConnection.php:348)
[stacktrace]
#0 /home/akasa/artywiz/vendor/laravel/framework/src/Illuminate/Redis/Connections/PhpRedisConnection.php(348): Redis->psubscribe(Array, Object(Closure))
#1 /home/akasa/artywiz/vendor/laravel/framework/src/Illuminate/Redis/RedisManager.php(140): Illuminate\\Redis\\Connections\\PhpRedisConnection->psubscribe(Array, Object(Closure))
#2 /home/akasa/artywiz/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Illuminate\\Redis\\RedisManager->__call('psubscribe', Array)
#3 /home/akasa/artywiz/app/Console/Commands/RedisSubscribe.php(89): Illuminate\\Support\\Facades\\Facade::__callStatic('psubscribe', Array)
#4 [internal function]: App\\Console\\Commands\\RedisSubscribe->handle()
#5 /home/akasa/artywiz/vendor/laravel/framework/src/Illuminate
@rolldone
rolldone / SearchableTrait.php
Created August 17, 2019 09:07
Improve bug Searchable, extend on it on your new laravel
<?php namespace App\Traits;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Nicolaslopezj\Searchable\SearchableTrait as ParentSearchableTraits;
/**
* Trait SearchableTrait
Jika pada saat create user namun tab autocomplete tidak jalan maka :
sudo chsh -s /bin/bash <username>
source :
https://askubuntu.com/questions/325807/arrow-keys-home-end-tab-complete-keys-not-working-in-shell
client list -> Melihat driver yang melakukan koneksi
info -> melihat isi penggunnaan redis
var Original = {
extend : function(props = null) {
var newOne = Object.assign({}, this);
newOne.super = Object.assign({}, newOne);
if (props != null) {
for(var key in props){
if(props[key].toString().includes('.super') == false){
if(key != 'construct'){
console.log('key',key);
newOne.super[key] = props[key];