Skip to content

Instantly share code, notes, and snippets.

yushine yushine

View GitHub Profile
@yushine
yushine / Crontab.class.php
Created Jun 19, 2018 — forked from GustavGenberg/Crontab.class.php
Easy crontab manager for PHP. Uses shell_exec!
View Crontab.class.php
<?php
class Crontab {
/*
(c) Gustav Genberg 2017
This script uses PHP shell_exec! Make sure it is enabled before using!
Also make sure that the user running this script (usually www-data) have access to the crontab command!
@yushine
yushine / sphp.sh
Last active Apr 14, 2018 — forked from w00fz/sphp.sh
PHP switcher
View sphp.sh
#!/bin/bash
# Check if command was ran as root.
if [[ $(id -u) -eq 0 ]]; then
echo "The command \"sphp\" should not be executed as root or via sudo directly."
echo "When a service requires root access, you will be prompted for a password as needed."
exit 1
fi
# Usage
@yushine
yushine / fix_git_sslread_9806.sh
Created Jun 24, 2017 — forked from entropiae/fix_git_sslread_9806.sh
git: how to solve "SSLRead() return error -9806" in OSX using brew
View fix_git_sslread_9806.sh
$ brew remove git
$ brew remove curl
$ brew install openssl
$ brew install --with-openssl curl
$ brew install --with-brewed-curl --with-brewed-openssl git
View redis-server
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis/redis.pid
@yushine
yushine / Encrypt.php
Created Jan 23, 2017 — forked from vishnukumarpv/Encrypt.php
Encrypt and Decrypt with php
View Encrypt.php
<?php
class Encrypt{
private function key( )
{
return $skey = "vishnu_kumar_aUlTIoQaBzk";
}
public function safe_b64encode($string) {
$data = base64_encode($string);
$data = str_replace(array('+','/','='),array('-','_',''),$data);
View gist:f15d421833275607de5dbcf0025c1ead
<?php
function encrypt($string, $key=5) {
$result = '';
for($i=0, $k= strlen($string); $i<$k; $i++) {
$char = substr($string, $i, 1);
$keychar = substr($key, ($i % strlen($key))-1, 1);
$char = chr(ord($char)+ord($keychar));
$result .= $char;
}
return base64_encode($result);
View gist:2834e8545e6515df3bdb1f66586e0f87
<?php
class encrypt
{
private $key;
private $uword;
private $eword;
private $letters;
/**
@yushine
yushine / Envoy.blade.php
Created Nov 1, 2016 — forked from joaosalless/Envoy.blade.php
Laravel Envoy Task Runner
View Envoy.blade.php
@servers(['staging' => 'root@192.168.0.99', 'production' => 'root@192.168.0.100'])
<?php
$app_name = 'l5eka';
$app_path = '/var/www/vhosts/'.$app_name;
$repo = 'https://github.com/vedovelli/l5eka';
$branch = 'aula4';
$github_token = ''; // GitHub OAuth token
$server_name = '192.168.0.99'; // IP ou domínio válido. Usado no nginx
View setInteral_setTimeout.md

pattern to replace setInterval with setTimeout

Register a task with setInterval and a interval is not desirable, since the task can take more time than the interval, so the compiler will skip through the current cycle. Replace setInterval with setTimeout with following pattern:

setInterval(function() {
    runSomething();
}, interval);

with

(function loop() {
@yushine
yushine / polling.md
Created Oct 26, 2016 — forked from ksdev-pl/polling.md
Polling (setInterval, setTimeout) #js
View polling.md

The setInterval Technique

Now, if you needed to poll your web service, your first instinct might be to do something like this with JavaScript and jQuery:

setInterval(function(){
    $.ajax({ url: "server", success: function(data){
        //Update your dashboard gauge
        salesGauge.setValue(data.value);
    }, dataType: "json"});
You can’t perform that action at this time.