Skip to content

Instantly share code, notes, and snippets.

View lockwooddev's full-sized avatar
🐍
*productive hissing*

Carlo Smouter lockwooddev

🐍
*productive hissing*
View GitHub Profile
var first = 0
var second = 1
var result = 0
do {
result = first + second
first = second
second = result
println(result)
} while result < 1000000000000
// for loop value range smaller then
for i in 0..<10 {
println(i)
}
println()
// regular style for loop
for var a = 0; a < 10; a++ {
println(a)
@lockwooddev
lockwooddev / gist:c5e0ff8887ab539502e7
Last active August 29, 2015 14:14
Swift: Functions
// Functions in Swift
func say(name: String) -> String {
return name
}
say("Hello World")
// Multiple parameters
// a & b & c are exactly the same
// a is shorthand written
// b is the long version
// c is the type infered version
var a: [Int] = [1, 2, 3, 4, 5]
var b: Array<Int> = [1, 2, 3, 4, 5]
var c: = [1, 2, 3, 4, 5]
var a: [String: Int] = ["a": 1, "b": 2]
@lockwooddev
lockwooddev / drone_lib_1.yaml
Last active February 23, 2019 08:24
Drone 1.x library multi machine pipeline
kind: pipeline
name: python27
steps:
- name: test
image: python:2.7-alpine3.9
commands:
- pip install -e .
- pip install -e .[tests]
- pytest
package yourpackage
import "testing"
func setup(t *testing.T) {
t.Log("setup")
}
func teardown(t *testing.T) {
t.Log("teardown")
package yourpackage
import (
"io/ioutil"
"net/http"
)
func GetData() ([]byte, error) {
resp, err := http.Get("http://example.com/api/v1/examples")
if err != nil {
package yourpackage
import (
"fmt"
"io/ioutil"
"net/http"
)
type ApiClient struct {
protocol string
package yourpackage
import (
"fmt"
"log"
"net/http"
"net/http/httptest"
"net/url"
"testing"
"time"
package job
type Job struct {
client ApiClient
}
func NewJob(client ApiClient) FetchJob {
return Job{client: client}
}