Skip to content

Instantly share code, notes, and snippets.

View slav123's full-sized avatar

Slawomir Jasinski slav123

View GitHub Profile
@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 / screen-res.swift
Created April 18, 2016 10:32
get width & height ios
private final let screenBound = UIScreen.mainScreen().bounds
private var screenWidth: CGFloat { return screenBound.size.width }
private var screenHeight: CGFloat { return screenBound.size.height }
@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 / twilio-sms.php
Created June 22, 2016 02:41
send SMS using PHP & Twilio REST API
<?php
$username = 'ACxxx';
$password = 'xxxx';
$body = "testing from twilio";
$data = http_build_query(['To' => '+61xxxxxx', 'From' => '+48xxxxx', 'Body' => $body]);
$context = stream_context_create([
'http' => [
@slav123
slav123 / PickerViewController.swift
Last active January 4, 2018 14:00
quick and dirty dynamic pickerView in Swift 3
//
// ViewController.swift
// picker
//
// Created by Slawomir Jasinski on 30/11/16.
// Copyright © 2016 Slawomir Jasinski. All rights reserved.
//
import UIKit
@slav123
slav123 / delete.sql
Created March 28, 2017 07:52
MySQL select records older then... in timestamp
SELECT id, DATE_FORMAT(FROM_UNIXTIME(`time`), '%e %b %Y') AS 'date_formatted' FROM api_logs WHERE `time` < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 3 MONTH)) ORDER BY id DESC
@slav123
slav123 / mon.sh
Created April 7, 2017 09:44
simple way to watch and restart php worker
#!/bin/sh
SERVICE_RUN="/usr/bin/php /home/ec2-user/docker/index.php worker"
SERVICE="/usr/bin/php"
if ps ax | grep -v grep | grep $SERVICE > /dev/null; then echo -n ""$SERVICE" : "running","; else echo -n ""$SERVICE" : "not running","; $SERVICE_RUN; fi
@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 / .htaccess
Last active June 13, 2017 09:25
CodeIgniter htaccess
SetEnv CI_ENV "testing"
# Options
Options -Multiviews
Options +FollowSymLinks
#Enable mod rewrite
RewriteEngine On
#the location of the root of your site
#if writing for subdirectories, you would enter /subdirectory
@slav123
slav123 / .netrc
Created July 12, 2017 08:04
mc FTP
MC is a console file manager. It supports FTP connections, and in my experience is faster in FTP than both Krusader and Gnome Commander.
However, the default FTP connection format string [username[:password]@]hostname has a drawback of not allowing the use of usernames with ‘@’-symbol in them – which is very common for virtual hostings.
One of the solutions is (done in your home directory):
if there is no .netrc file in your home directory — touch .netrc && chmod 600 .netrc
mcedit .netrc (or use vi, nano, or any other editor you prefer)
add the following line to the file (replace all-caps words with your actual credentials): machine HOSTNAME login USER@HOSTNAME password PASSWORD