Skip to content

Instantly share code, notes, and snippets.

View Blquinn's full-sized avatar

Benjamin Quinn Blquinn

View GitHub Profile
@Blquinn
Blquinn / scheduler_lock.go
Last active April 29, 2024 22:53
Global scheduler lock implementation using redis, daily scheduled task using redis + db
package main
import (
"github.com/go-redis/redis"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
"github.com/robfig/cron"
"github.com/sirupsen/logrus"
"time"
)
@Blquinn
Blquinn / chan_test.go
Created March 8, 2019 02:26
Benchmark of go channels throughput
package main
import (
"testing"
"time"
)
func BenchmarkChanByteArray(b *testing.B) {
c := make(chan []byte, 1)
@Blquinn
Blquinn / dynamic_json.go
Created August 21, 2019 13:49
Unmarshaling a dynamic with golang encoding/json
package main
import (
"encoding/json"
"fmt"
)
type Envelope struct {
Type string
Payload interface{}
@Blquinn
Blquinn / Dockerfile
Created August 21, 2019 21:31
XGBoost alpine dockerfile
FROM 'alpine'
WORKDIR /xgboost
RUN apk add --update git cmake make gfortran python3 python3-dev py-pip openblas lapack-dev libexecinfo-dev libstdc++ libgomp build-base && \
python3.7 -m pip install numpy==1.15.4 scipy==1.2.0 pandas==0.23.4 scikit-learn==0.20.2 && \
git clone --recursive -b release_0.90 https://github.com/dmlc/xgboost.git && \
cd xgboost && \
mkdir build && \
cd build && \
@Blquinn
Blquinn / Deserialize.kt
Created August 25, 2019 22:17
Example of deserializing list of dynamic json with jackson.
data class Envelope(
val type: String,
val payload: JsonNode
)
data class Thing1(
val property: String
)
@Blquinn
Blquinn / variadic_opt.go
Created September 5, 2019 19:37
Hacking variadics to have optional arguments
package main
import (
"net/http"
"encoding/json"
)
// Using variadic (hack) to default the response code to 200
func sendJSON(w http.ResponseWriter, v interface{}, status ...int) {
st := http.StatusOK
@Blquinn
Blquinn / args_test.go
Created January 23, 2020 04:02
Unmarshalling json array into function arguments
package args
import (
"encoding/json"
"errors"
"fmt"
"reflect"
"testing"
)
@Blquinn
Blquinn / Tree.tsx
Created February 15, 2023 14:55
Solid-js tree store
import { render } from "solid-js/web";
import { createSignal, For, Show } from "solid-js";
import { createStore } from "solid-js/store";
const [state, setState] = createStore<TreeNode[]>([
{
value: "foo",
children: [
{ value: "bar", children: [] },
{ value: "baz", children: [{ value: "quux", children: [] }] },
@Blquinn
Blquinn / main.dart
Last active May 8, 2023 15:36
Opacity Animation Example
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override