Skip to content

Instantly share code, notes, and snippets.

View dmcyk's full-sized avatar

Damian Malarczyk dmcyk

View GitHub Profile
@dmcyk
dmcyk / Swift_array_3vs4.swift
Last active May 19, 2017 14:08
Works fine with Swift 3, but with 4 (17 May 2017 snapshot) I get following error `'map' produces '[T]', not the expected contextual result type '[(Element)]'`
public extension Array where Element: FloatingPoint {
func normalized(scale: Element) -> [Element] {
guard let maxVal = self.max(), let minVal = self.min() else {
return []
}
let diff = maxVal - minVal
return self.map { val in
((val - minVal) / diff) * scale
}
}
@dmcyk
dmcyk / setupLLVM.sh
Last active April 26, 2017 17:25
setupLLVM.sh
#!/bin/bash
ver=`lsb_release -r | awk '{print $2}'`
db=""
dbSrc=""
if [[ $ver == "14.04" ]]; then
db="http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main"
dbSrc="http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main"
elif [[ $ver == "15.10" ]]; then
db="http://apt.llvm.org/wily/ llvm-toolchain-wily-4.0 main"
@dmcyk
dmcyk / MSIwG_setup.sh
Last active April 27, 2017 18:58
MSIwG_setup
#!/bin/bash
errLogPath=".err.log"
exec 3>&1
exec > /dev/null 2> $errLogPath
echo "" > $errLogPath
function echoStd {
while (( "$#" )); do
echo $1 >&3
shift
@dmcyk
dmcyk / sat
Created January 8, 2017 22:39
p cnf 20 91
4 -18 19 0
3 18 -5 0
-5 -8 -15 0
-20 7 -16 0
10 -13 -7 0
-12 -9 17 0
17 19 5 0
-16 9 15 0
11 -5 -14 0
import SwiftyCurl
import Foundation
import CCurl
///// SwiftyCurl
var request = cURLRequest(url: URL(string: "https://jsonplaceholder.typicode.com/posts")!,
method: .get)
request.contentType = .json
#!/bin/bash
sudo su -
echo 5 > /proc/sys/net/ipv4/route/gc_timeout
echo 5 > /proc/sys/net/ipv4/neigh/default/gc_stale_time
#!/bin/bash
sudo apt-get install php-fpm php-mysql
@dmcyk
dmcyk / nginx.sh
Last active December 21, 2017 16:57
#!/bin/bash
sudo apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev unzip libssl-dev
NPS_VERSION=1.12.34.3-stable
cd
wget https://github.com/pagespeed/ngx_pagespeed/archive/v${NPS_VERSION}.zip
unzip v${NPS_VERSION}.zip
cd ngx_pagespeed-${NPS_VERSION}/
NPS_RELEASE_NUMBER=${NPS_VERSION/beta/}
NPS_RELEASE_NUMBER=${NPS_VERSION/stable/}