Skip to content

Instantly share code, notes, and snippets.

View metakeule's full-sized avatar
💭
I may be slow to respond.

metakeule metakeule

💭
I may be slow to respond.
  • Asunción / Paraguay
View GitHub Profile
@aliuygur
aliuygur / desc.md
Last active July 22, 2022 09:48
removes duplicate values in given slice

this algorithm 10x faster than https://www.dotnetperls.com/duplicates-go and zero allocation

➜  api git:(master) ✗ go test -v -bench=. main_test.go
=== RUN   TestSliceUniq
--- PASS: TestSliceUniq (0.00s)
BenchmarkSliceUniq-4             3000000               439 ns/op               0 B/op          0 allocs/op
BenchmarkRemoveDuplicates-4       500000              4599 ns/op             571 B/op          8 allocs/op
PASS
@mikespook
mikespook / hello.c
Created July 2, 2016 01:40
GIMP Plug-in in Golang
// Comes from http://developer.gimp.org/writing-a-plug-in/1/hello.c
#include <libgimp/gimp.h>
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
with table_stats as (
select psut.relname,
psut.n_live_tup,
1.0 * psut.idx_scan / greatest(1, psut.seq_scan + psut.idx_scan) as index_use_ratio
from pg_stat_user_tables psut
order by psut.n_live_tup desc
),
table_io as (
select psiut.relname,
sum(psiut.heap_blks_read) as table_page_read,
@xavriley
xavriley / Dockerfile
Last active August 21, 2019 15:31
Sonic Pi Dockerfile take 2
FROM ruby:2.1
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install \
git-core \
sudo \
supercollider-server \
libqscintilla2-dev \
libqscintilla2-l10n \
cmake \
@timyates
timyates / fizzbuzz.pony
Last active August 29, 2015 14:20
First go at FizzBuzz in pony-lang
type FbVal is (U64, (String|None))
type FbNext is (FbActor | None)
actor FbActor
var _env : Env
var _mod : U64
var _word : String
var _next : FbNext
new create(env: Env, mod: U64, word : String, next: FbNext = None) =>
/*
The MIT License (MIT)
Copyright (c) 2014
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@webcss
webcss / eventsmixin.js
Last active August 9, 2016 12:44
PubSub mixin using CustomEvents
// utilizes the browser eventsystem
// usefull in cases where you need communication between independent components
// registered events are automatically removed onunload with preserving any other onunload handler
var eventsMixin = function(target) {
var _subscriptions = [];
target.broadcast = function(type, payload) {
var ev = new CustomEvent(type, {
detail: payload,
@lee8oi
lee8oi / startProcess.go
Last active January 4, 2024 01:19
Using os.StartProcess() in Go for platform-independent system command execution.
package main
import (
"os"
"os/exec"
)
func Start(args ...string) (p *os.Process, err error) {
if args[0], err = exec.LookPath(args[0]); err == nil {
var procAttr os.ProcAttr
@mark-kubacki
mark-kubacki / create-all.sh
Last active September 21, 2023 07:50
a dummy Certificate Authority for development and testing
#!/bin/bash
#
# Copyright (c) 2015 W. Mark Kubacki <wmark@hurrikane.de>
# Licensed under the terms of the RPL 1.5 for all usages
# http://www.opensource.org/licenses/rpl1.5
#
set -e -o pipefail
CAsubj="/C=DE/ST=Niedersachsen/L=Hannover/O=Dummy CA/CN=Sign-It-All"
@lee8oi
lee8oi / goshell.go
Last active December 18, 2023 18:17
Running system commands interactively in Go using os/exec
package main
import (
"os"
"os/exec"
)
func Command(args ...string) {
cmd := exec.Command(args[0], args[1:]...)
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr