Skip to content

Instantly share code, notes, and snippets.

View slav123's full-sized avatar

Slawomir Jasinski slav123

View GitHub Profile
@slav123
slav123 / kill-all-php-fpm.sh
Last active April 14, 2021 09:12 — forked from bmichalski/kill-all-php-fpm.sh
Kill all php-fpm processes
sudo kill -9 `sudo ps -ef | grep php-fpm | grep -v grep | awk '{print $2}'`
ps -A | grep php-fpm | awk '{print $1}' | xargs kill -9 $1
@slav123
slav123 / go-install.sh
Last active July 10, 2019 09:55 — forked from mlabouardy/go-install.sh
Setup Go environment variables
# GOROOT is the location where Go package is installed on your system
export GOROOT=/usr/lib/golang
# GOPATH is the location of your work directory
export GOPATH=$HOME/go
# PATH in order to access go binary system wide
export PATH=$PATH:$GOROOT/bin
@slav123
slav123 / gist:2075589367aa526cce6ef0aaf68aba75
Created March 8, 2018 09:45 — forked from bds/gist:2207826
Convert files from .scss to .sass
sass-convert -F scss -T sass application_styles.css.scss application_styles.css.sass
@slav123
slav123 / caddy
Created May 11, 2017 11:08 — forked from monobilisim/caddy
Caddy init.d file for CentOS 6
#!/bin/sh
### BEGIN INIT INFO
# Provides: caddy
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the caddy web server
# Description: starts caddy using start-stop-daemon
### END INIT INFO
@slav123
slav123 / selenium-php-webdriver-cheatsheet.md
Created May 23, 2016 10:20 — forked from aczietlow/selenium-php-webdriver-cheatsheet.md
Cheat sheet for using php webdriver (facebook/webdriver).

Webdriver PHP API workthough

  • Open a browser

    # start an instance of firefox with selenium-webdriver
    
    $browser_type = 'firefox'
    $host = 'http://localhost:4444/wd/hub'
    

$capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => $browser_type);

@slav123
slav123 / update-route53.sh
Last active April 8, 2016 08:35 — forked from phybros/update-route53.sh
BASH Script to keep Route53 updated with your current external IP address
#!/bin/bash
# Hosted Zone ID e.g. BJBK35SKMM9OE
ZONEID="enter zone id here"
# The CNAME you want to update e.g. hello.example.com
RECORDSET="enter cname here"
# More advanced options below
# The Time-To-Live of this recordset
@slav123
slav123 / jquery.unserialize.js
Created January 22, 2016 20:42 — forked from rcmachado/jquery.unserialize.js
$.unserialize for jQuery
/**
* $.unserialize
*
* Takes a string in format "param1=value1&param2=value2" and returns an object { param1: 'value1', param2: 'value2' }. If the "param1" ends with "[]" the param is treated as an array.
*
* Example:
*
* Input: param1=value1&param2=value2
* Return: { param1 : value1, param2: value2 }
*
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="true"
stopOnFailure="false"
backupGlobals="false"
backupStaticAttributes="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
// Author - Santosh Rajan
import Foundation
let string = "{\"name\": \"John\", \"age\": 35, \"children\": [\"Jack\", \"Jill\"]}"
func JSONParseDictionary(jsonString: String) -> [String: AnyObject] {
if let data = jsonString.dataUsingEncoding(NSUTF8StringEncoding) {
if let dictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions(0), error: nil) as? [String: AnyObject] {
return dictionary
//npm install b64url
//A signed_request for testing:
//WGvK-mUKB_Utg0l8gSPvf6smzacp46977pTtcRx0puE.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjEyOTI4MjEyMDAsImlzc3VlZF9hdCI6MTI5MjgxNDgyMCwib2F1dGhfdG9rZW4iOiIxNTI1NDk2ODQ3NzczMDJ8Mi5ZV2NxV2k2T0k0U0h4Y2JwTWJRaDdBX18uMzYwMC4xMjkyODIxMjAwLTcyMTU5OTQ3NnxQaDRmb2t6S1IyamozQWlxVldqNXp2cTBmeFEiLCJ1c2VyIjp7ImxvY2FsZSI6ImVuX0dCIiwiY291bnRyeSI6ImF1In0sInVzZXJfaWQiOiI3MjE1OTk0NzYifQ
function parse_signed_request(signed_request, secret) {
encoded_data = signed_request.split('.',2);
// decode the data
sig = encoded_data[0];
json = base64url.decode(encoded_data[1]);
data = JSON.parse(json); // ERROR Occurs Here!