Skip to content

Instantly share code, notes, and snippets.

View jkuri's full-sized avatar
🏠
Working from home

Jan Kuri jkuri

🏠
Working from home
View GitHub Profile
@dschowta
dschowta / protobuf_struct_converter.go
Created August 6, 2020 05:55
golang: grpc: interface or map type conversion to protobuf struct using protojson .
// Conversion of interface{} or map[string]interface{} types to protobuf struct ("google/protobuf/struct.proto").
package codec
import (
"encoding/json"
structpb "github.com/golang/protobuf/ptypes/struct"
"google.golang.org/protobuf/encoding/protojson"
)
@CJEnright
CJEnright / gzip.go
Last active December 19, 2023 19:40
Idiomatic golang net/http gzip transparent compression, an updated version of https://gist.github.com/bryfry/09a650eb8aac0fb76c24
package main
import (
"net/http"
"compress/gzip"
"io/ioutil"
"strings"
"sync"
"io"
)
@jonjack
jonjack / add-update-refresh-github-access-token-on-mac.md
Last active April 24, 2024 10:05
Adding & Updating GitHub Access Token on Mac

Using an Access Token for the first time

Follow the instructions on Github to Create an Access Token in Github

Configure Git to use the osxkeychain

By default, git credentials are not cached so you need to tell Git if you want to avoid having to provide them each time Github requires you to authenticate. On Mac, Git comes with an “osxkeychain” mode, which caches credentials in the secure keychain that’s attached to your system account.

You can tell Git you want to store credentials in the osxkeychain by running the following:-

@abereghici
abereghici / token-interceptor.service.ts
Last active December 29, 2023 17:54
Angular Tutorial — Implement Refresh Token with HttpInterceptor
// src/app/services/token-interceptor.service.ts
import { Injectable } from "@angular/core";
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from "@angular/common/http";
import { AuthenticationService } from "../authentication.service";
import { Observable } from "rxjs/Observable";
import { BehaviorSubject } from "rxjs/BehaviorSubject";
@Injectable()
export class RefreshTokenInterceptor implements HttpInterceptor {
@jkuri
jkuri / README.md
Created March 25, 2018 01:53
Output all video capture devices with all video modes available on MacOS using AVFoundation framework

Output all video capture devices with all video modes available on MacOS using AVFoundation

Compile program using:

clang -o video_capture_devices video_capture_devices.m -framework Foundation -framework AVFoundation -framework CoreMedia

Sample output:

@XerxesNoble
XerxesNoble / animate_values.js
Last active March 9, 2024 13:07
Basic javascript linear value animation that can accept easing functions and provides update & complete callbacks
/**
* @desc Basic linear value animation that can accept simple easing functions and provides update & complete callbacks
* @param {Object} values - Object with numerical values. eg. { value1: 0, value2: 20, someKey: 55 }
* @param {Number} duration - How long (in milliseconds) the animation will be
* @param {Object} options - target values, update callback & complete callback
* @param {Function} [options.onComplete=(values) => values] - Callback that fires once animation is complete
* @param {Function} [options.onUpdate=(values) => values] - Callback that fires when animation frame updates
* @param {Function} [options.ease=(t) => t] - easing method eg. https://gist.github.com/gre/1650294
* @example
*
@eliranmal
eliranmal / show-ansi-colors.sh
Last active November 7, 2022 07:30
spits N ansi colors to the terminal
#!/usr/bin/env sh
usage() {
echo "show-ansi-colors <n>"
exit 0
}
(( $# < 1 )) && usage
show_ansi_colors() {
@peterhellberg
peterhellberg / graceful.go
Last active August 20, 2023 08:49
*http.Server in Go 1.8 supports graceful shutdown. This is a small example.
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"time"
)
@mowings
mowings / masq.sh
Last active September 25, 2023 20:00
script to get xet xhyve working with all vpn interfaces
#!/bin/bash
interfaces=( $(netstat -in | egrep 'utun\d .*\d+\.\d+\.\d+\.\d+' | cut -d ' ' -f 1) )
rulefile="rules.tmp"
echo "" > $rulefile
sudo pfctl -a com.apple/tun -F nat
for i in "${interfaces[@]}"
do
RULE="nat on ${i} proto {tcp, udp, icmp} from 192.168.64.0/24 to any -> ${i}"
echo $RULE >> $rulefile
done
@eloypnd
eloypnd / dnsmasq_setup_osx.md
Last active March 23, 2024 00:25
wildcard DNS record on OS X in localhost development with dnsmasq

wildcard DNS in localhost development

$ brew install dnsmasq
   ...
$ cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
  • edit /usr/local/etc/dnsmasq.conf
address=/local/127.0.0.1