Skip to content

Instantly share code, notes, and snippets.

View slav123's full-sized avatar

Slawomir Jasinski slav123

View GitHub Profile
@slav123
slav123 / upload.swift
Created May 11, 2015 06:42
upload image from UIPicker
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
// do something with selectedImage and originalImage
let timage = UIImageJPEGRepresentation(image, 1.0);
if image != nil {
//UIImageJPEGRepresentation(selectedImage, <#compressionQuality: CGFloat#>)
upload(.POST, "http://api.localhost/image", timage)
.progress { (bytesWritten, totalBytesWritten, totalBytesExpectedToWrite) in
@slav123
slav123 / gs.go
Last active August 29, 2015 14:21
Uploading to google storage using AWS S3 libraries
package main
import (
"github.com/goamz/goamz/aws"
"github.com/goamz/goamz/s3"
"log"
)
var (
AccessKeyId, SecretAccessKey, Bucket string
@slav123
slav123 / swipe-swift.swift
Created May 25, 2015 06:51
show swipe options in tableview
// swipe actions
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? {
/*var superAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Contact:", handler: { (action: UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in
let callMenu = UIAlertController(title: nil, message: "Contact using", preferredStyle: .ActionSheet)
let phoneAction = UIAlertAction(title: "Phone", style: UIAlertActionStyle.Default, handler: nil)
let messageAction = UIAlertAction(title: "Message", style: UIAlertActionStyle.Default, handler: nil)
let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil)
@slav123
slav123 / server.go
Created May 29, 2015 01:25
golang channels examples with tcp server
package main
import (
"io"
"log"
"net"
"bytes"
"bufio"
"strings"
"time"
@slav123
slav123 / styles.swift
Created June 17, 2015 23:41
styling with NSFont
import UIKit
func imageFromContextOfSize(size:CGSize, closure:() -> ()) -> UIImage {
UIGraphicsBeginImageContextWithOptions(size, false, 0)
closure()
let result = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return result
@slav123
slav123 / swipe.swift
Created June 17, 2015 23:47
gesture recognizzers
override func viewDidLoad() {
super.viewDidLoad()
var swipeRight = UISwipeGestureRecognizer(target: self, action: "respondToSwipeGesture:")
swipeRight.direction = UISwipeGestureRecognizerDirection.Right
self.view.addGestureRecognizer(swipeRight)
var swipeDown = UISwipeGestureRecognizer(target: self, action: "respondToSwipeGesture:")
swipeDown.direction = UISwipeGestureRecognizerDirection.Down
self.view.addGestureRecognizer(swipeDown)
@slav123
slav123 / config.php
Created June 18, 2015 04:53
CodeIgniter redis sessions
<?php
$config['sess_driver'] = 'redis';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = "127.0.0.1:6379";
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
@slav123
slav123 / table.html
Created June 22, 2015 02:38
angled headers
<div class="scrollable-table">
<table class="table table-striped table-header-rotated">
<thead>
<tr>
<!-- First column header is not rotated -->
<th></th>
<!-- Following headers are rotated -->
<th class="rotate-45"><div><span>Column header 1</span></div></th>
<th class="rotate-45"><div><span>Column header 2</span></div></th>
<th class="rotate-45"><div><span>Column header 3</span></div></th>
@slav123
slav123 / table.css
Created June 22, 2015 02:39
css for angled headers
.table-header-rotated th.row-header{
width: auto;
}
.table-header-rotated td{
width: 40px;
border-top: 1px solid #dddddd;
border-left: 1px solid #dddddd;
border-right: 1px solid #dddddd;
vertical-align: middle;
@slav123
slav123 / make_intval.php
Last active September 1, 2016 11:01
make all elements in array integers
<?php
// get only id's
$steps_in_stage = array_map('intval', $array);