Skip to content

Instantly share code, notes, and snippets.

View khaelou's full-sized avatar
💾
Writing Code

My-khael Pierce khaelou

💾
Writing Code
View GitHub Profile
@prachikhadke
prachikhadke / nested-goroutines
Created May 7, 2020 00:05
Calling go routines from go routines
package main
import (
"fmt"
"time"
)
func SayHello(name string) {
fmt.Printf("Hello %s!\n", name)
}
@mecid
mecid / Calendar.swift
Last active August 23, 2024 16:39
SwiftUI Calendar view using LazyVGrid
import SwiftUI
extension Calendar {
func generateDates(
inside interval: DateInterval,
matching components: DateComponents
) -> [Date] {
var dates: [Date] = []
dates.append(interval.start)
@miguelmota
miguelmota / command_exists.go
Last active July 31, 2024 17:15
Golang check if command exists
package main
import (
"log"
"os/exec"
)
func main() {
path, err := exec.LookPath("ls")
if err != nil {
//Xib class
import UIKit
protocol CustomViewDelegate: class { // make this class protocol so you can create `weak` reference
func goToNextScene()
}
class CustomView: UIView {
weak var delegate: CustomViewDelegate? // make this `weak` to avoid strong reference cycle b/w view controller and its views
@brunosxs
brunosxs / savenload.gd
Last active July 9, 2020 22:30
Godot Quick Tips 02: Simple save and load methods for godot engine with dir and file handling
# Created by BrunoSXS
# LICENSED UNDER MIT
var save_slot = 0 # Just like classic JRPs, change the slot to save in a different place
var current_save_game # This is the contents of the save file, for now we just declare it
var default_save = {"money":0,"powers":null} # The default save contents, if there is no save file to load, then, the current_save_game gets its contents from this variable and then creates a save file with it
func _ready():
current_save_game = load_game(save_slot) if typeof(load_game(save_slot)) == TYPE_DICTIONARY else default_save # This is the first loading, when the game starts.
@brunosxs
brunosxs / create_timer.gd
Last active April 22, 2022 20:02
Godot Quick Tips 01: The create_timer() helper for waiting X seconds
# Available only in the 2.2 legacy branch and posterior versions
func _ready():
# The old way:
print("HELLO") # Code before the yield
# Setting up the yield:
var t = Timer.new() # Create a new Timer node
t.set_wait_time(5.5) # Set the wait time
add_child(t) # Add it to the node tree as the direct child
@evillemez
evillemez / wait-groups.go
Created October 16, 2016 00:50
Playing with WaitGroup in nested goroutines
package main
import (
"crypto/rand"
"fmt"
"math/big"
"os"
"sync"
"time"
)
@tchayen
tchayen / script-calculator.js
Last active November 14, 2023 02:47
Javascript calculator using Reverse Polish notation and Shunting-yard algorithm
// function connecting algorithm with outer world
function updateCalculator(event) {
var expression = document.getElementById("calculator").value;
var result = calculate(expression);
document.getElementById('calculatorResult').innerHTML = result;
}
function calculate(expression) {
@trkrameshkumar
trkrameshkumar / db.go
Created September 6, 2015 07:19
Get get number of rows using sql in golang
package main
import (
"database/sql"
"fmt"
_ "github.com/lib/pq"
)
const (
DB_USER = "ramesh"
@saelo
saelo / decorator.go
Created March 8, 2015 19:45
Decorators in Go
package main
import (
"fmt"
"reflect"
)
func Decorate(impl interface{}) interface{} {
fn := reflect.ValueOf(impl)