Skip to content

Instantly share code, notes, and snippets.

View jredh's full-sized avatar
Go Braves!

jredh

Go Braves!
View GitHub Profile
@bartoszmajsak
bartoszmajsak / prepare-commit-msg.sh
Last active March 20, 2024 08:12
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
@thomas11
thomas11 / gist:2909362
Created June 11, 2012 09:52
Log memory usage every n seconds in Go #golang
import (
"runtime"
"time"
)
...
go func() {
for {
var m runtime.MemStats
@JustLikeIcarus
JustLikeIcarus / HtmlHelpersIfExtension.cs
Last active December 15, 2015 20:40
Extend MVC Html Helpers to return if an evaluation returns true. Example: @Html.ActionLink("Test Link", "SomeAction", "SomeController").If(Roles.GetRolesForUser().Contains("Admin"))
namespace System.Web.Mvc
{
public static class HelperExtensions
{
public static MvcHtmlString If(this MvcHtmlString value, bool evaluation)
{
return evaluation ? value : MvcHtmlString.Empty;
}
}
}
@lunny
lunny / diskinfo.go
Created March 28, 2014 08:59
Disk Info for Golang
package main
import (
"fmt"
"syscall"
)
type DiskStatus struct {
All uint64 `json:"all"`
Used uint64 `json:"used"`
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active July 28, 2024 05:15
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
require('GlobalStrings')
-- generated from s_bonusStatStringTags
local bonusStats = {
[0] = "ITEM_MOD_MANA_SHORT",
[1] = "ITEM_MOD_HEALTH_SHORT",
[3] = "ITEM_MOD_AGILITY_SHORT",
[4] = "ITEM_MOD_STRENGTH_SHORT",
[5] = "ITEM_MOD_INTELLECT_SHORT",
[6] = "ITEM_MOD_SPIRIT_SHORT",
package main
import (
"bufio"
"log"
"os"
)
var concurrency = 100
@cvogt
cvogt / pre-commit-hook-install.sh
Created June 16, 2015 19:27
git pre-commit hook for Scala compile and format checking (put both in your git project root, needs to be installed in each clone)
#!/bin/sh
cd "$(dirname "$0")"
touch .git/hooks/pre-commit
rm .git/hooks/pre-commit
ln -s ../../pre-commit-hook.sh .git/hooks/pre-commit
@syafiqfaiz
syafiqfaiz / how-to-copy-aws-rds-to-local.md
Last active June 22, 2024 20:31
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x