Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
lamarmarshall / index.html
Last active October 15, 2017 03:10
nodejs electron starter
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<h1>hello world</h1>
</body>
</html>
@lamarmarshall
lamarmarshall / home.js
Created October 15, 2017 03:55
electron open new window
const remote = require('electron').remote
const main = remote.require('./index.js')
var buttton = document.getElementById("btn")
buttton.addEventListener('click', () => {
main.openWindow("pagetwo")
})
document.body.appendChild(button)
@lamarmarshall
lamarmarshall / closewindow.js
Created October 15, 2017 03:59
electron close window
const remote = require('electron').remote
const main = remote.require('./index.js')
var buttton = document.getElementById("btn")
buttton.addEventListener('click', () => {
var window = remote.getCurrentWindow().close()
main.openWindow("pagetwo")
})
@lamarmarshall
lamarmarshall / oop.go
Created October 20, 2017 01:38
go oop, class, string conversion, int conversion
package main
import (
"fmt"
"strconv"
)
type Person struct {
name string
age int
@lamarmarshall
lamarmarshall / file.docker
Created October 20, 2017 02:29
docker create nginx container
docker container run --publish 80:80 nginx
@lamarmarshall
lamarmarshall / variadic.go
Created October 25, 2017 04:22
go variadic functions, go functions with multiple arguments, go array into funcs
package main
import "fmt"
func Addall(nums ...int) int {
res := 0
for _, n := range nums {
res += n
}
return res
@lamarmarshall
lamarmarshall / inlinefunc.go
Created October 25, 2017 04:31
go inline function, closure
package main
import "fmt"
func main() {
sayname := func() string {
return "may name is lamar"
}
@lamarmarshall
lamarmarshall / callback.go
Created October 25, 2017 04:56
go callback, function as argument
package main
import "fmt"
func addName(name string, callback func(string)) {
callback(name)
}
func main() {
addName("lamar", func(nm string) {
@lamarmarshall
lamarmarshall / defer.go
Created October 25, 2017 22:28
go anonymous self executing function, defer
package main
import "fmt"
func main() {
nwmi := func() {
fmt.Println("nigga we made it")
}
@lamarmarshall
lamarmarshall / slice.go
Created October 26, 2017 00:23
go slice append
package main
import "fmt"
func main() {
sls := make([]int, 0, 100)
sls = append(sls, 1, 2, 3, 4, 5)
fmt.Printf("type: %T capacity: %v\n values : %v", sls, cap(sls), sls)
}