Skip to content

Instantly share code, notes, and snippets.

View alexsoft's full-sized avatar

Alex Plekhanov alexsoft

View GitHub Profile
@alexsoft
alexsoft / gist:9051027
Created February 17, 2014 13:58
ssh alias
Host srv1
User root
Port 225
HostName 8.8.8.8
@servers(['prod' => 'user@example.com', 'dev' => 'user@dev.example.com'])
@task('deploy', ['on' => $server])
cd /project/folder
git pull
php artisan cache:clear
@endtask
In task body you can write any commands for your deploy
and then deploy using just
@alexsoft
alexsoft / task.js
Last active August 29, 2015 14:25
Limit-Offset-Task
function range(r,a,o){var n,t,e,N=[],i=o||1,s=!1;if(isNaN(r)||isNaN(a)?isNaN(r)&&isNaN(a)?(s=!0,n=r.charCodeAt(0),t=a.charCodeAt(0)):(n=isNaN(r)?0:r,t=isNaN(a)?0:a):(n=r,t=a),e=n>t?!1:!0)for(;t>=n;)N.push(s?String.fromCharCode(n):n),n+=i;else for(;n>=t;)N.push(s?String.fromCharCode(n):n),n-=i;return N}function getItems(r,a){return a>=count?[]:r+a>count?range(a+1,count):range(a+1,a+r)}var count=Math.floor(15e3*Math.random());
// getItems(limit, offset) {...}
// limit = 1000 optimal
var result = [];
console.log(result);
@alexsoft
alexsoft / gist:3790242
Last active October 11, 2015 02:38
HTML: Starting Template
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Random title</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="css/bootstrap.css" rel="stylesheet">
@alexsoft
alexsoft / gist:4453570
Created January 4, 2013 15:43
Python: MySQLdb
import MySQLdb
db = MySQLdb.connect(host="localhost",\
user="USERNAME",\
passwd="PASSWORD",\
db="DB_NAME",\
charset="utf8")
cursor = db.cursor()
sql = "SELECT a,b FROM sometable"
@alexsoft
alexsoft / Google Chrome
Last active December 28, 2015 13:09
shell: installers of useful things (Ubuntu 12.04)
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install google-chrome-stable
@alexsoft
alexsoft / gist:bbd711b5decbfadd71658c32df74d2e3
Created August 22, 2016 10:28
Generate SRI hash for script and/or link html tag
cat FILENAME.js | openssl dgst -sha384 -binary | openssl enc -base64 -A

Keybase proof

I hereby claim:

  • I am alexsoft on github.
  • I am alexplekhanov (https://keybase.io/alexplekhanov) on keybase.
  • I have a public key ASCav97IiC4u0oDXde5AO8lYoFgUE1hNytrea7HPHbEW7Qo

To claim this, I am signing this object:

@alexsoft
alexsoft / Preferences.sublime-settings
Last active January 21, 2018 11:29
JSON: Sublime_3_Settings
{
"always_prompt_for_file_reload": false,
"always_show_minimap_viewport": false,
"animation_enabled": true,
"atomic_save": true,
"auto_close_tags": true,
"auto_complete": true,
"auto_complete_commit_on_tab": false,
"auto_complete_delay": 50,
"auto_complete_selector": "source - comment, meta.tag - punctuation.definition.tag.begin",
@alexsoft
alexsoft / .php_cs.laravel.php
Created July 17, 2019 14:41 — forked from laravel-shift/.php-cs-fixer.php
PHP CS Fixer - Laravel Ruleset
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'phpdoc_indent' => true,
'binary_operator_spaces' => [
'operators' => ['=>' => null]
],