Skip to content

Instantly share code, notes, and snippets.

View nguyenbathanh's full-sized avatar

Thanh Nguyen nguyenbathanh

View GitHub Profile
@fabd
fabd / install ruby and jekyll on mac mini m1 apple silicon.md
Last active August 22, 2023 00:27
Install JEKYLL for GITHUB PAGES on Mac Mini M1 ( AUGUST 2021 )

NOTES

  • I only care about running jekyll for Github Pages.
  • ruby 3.x doesn't seem to work correctly with Jekyll
  • since I don't care about any other users on my machine, I will NOT install gems to user folder to simplify the process

Double check the pre-installed version of RUBY we DONT want (version 2.6)

$ ruby -v
@velopert
velopert / CounterManager.m
Created April 25, 2021 11:26
React Native iOS Native Component with Swift
#import <React/RCTViewManager.h>
@interface RCT_EXTERN_MODULE(CounterManager, RCTViewManager)
RCT_EXPORT_VIEW_PROPERTY(value, NSNumber)
RCT_EXPORT_VIEW_PROPERTY(leftButtonText, NSString)
RCT_EXPORT_VIEW_PROPERTY(rightButtonText, NSString)
RCT_EXPORT_VIEW_PROPERTY(onPressLeftButton, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onPressRightButton, RCTDirectEventBlock)
@Gazzell
Gazzell / .eslintrc
Last active January 31, 2024 18:28
React, typescript, use craco to set custom tests paths and import aliases
{
"extends": [
"eslint-config-react-app"
],
"plugins": ["react", "import"],
"rules": {
"import/no-unresolved": "error"
},
"settings": {
"import/parsers": {
@markmichon
markmichon / devto.js
Created March 9, 2020 02:04
Dev.to API client example
const fetch = require("isomorphic-unfetch");
const querystring = require("querystring");
class DevTo {
constructor(config) {
this.api_key = config.api_key;
this.basePath = "https://dev.to/api";
}
request(endpoint = "", options = {}) {
let url = this.basePath + endpoint;
@ingconti
ingconti / CGRect+JSONCodable.swift
Last active June 19, 2023 04:27
real JSON encode / decode for CGRect
import Foundation
import CoreGraphics
// Apple does implement Codable, but is NOT really JSON and fails with arrys of CGRects.
extension CGRect {
func toDict()->Dict{
let d : Dict = [
"origin" : ["x" : self.origin.x, "y" : self.origin.y],
@francbartoli
francbartoli / demo.py
Created June 2, 2019 12:48 — forked from wshayes/demo.py
[Websocket demo for fastapi] example of broadcast using websockets for fastapi #fastapi #websockets
# From https://github.com/tiangolo/fastapi/issues/258
from typing import List
from fastapi import FastAPI
from starlette.responses import HTMLResponse
from starlette.websockets import WebSocket, WebSocketDisconnect
app = FastAPI()
@jj1bdx
jj1bdx / airspy-fmradion-blackhole.sh
Last active October 13, 2023 08:00
sox examples for macOS coreaudio and BlackHole
# conservative level setting
airspy-fmradion -E100 -t airspyhf -c freq=89700000 -F - | \
sox -t raw -e floating-point -b32 -r 48000 -c 2 -q - -t coreaudio "BlackHo" gain -24
# a bit more louder
airspy-fmradion -E100 -t airspyhf -c freq=89700000 -F - | \
sox -t raw -e floating-point -b32 -r 48000 -c 2 -q - -t coreaudio "BlackHo" gain -18
# DO NOT SET TO `gain 0` or as is - level too loud for QuickTime Player recorder
@deeshrestha
deeshrestha / bootstrap-4.blade.php
Created December 6, 2018 18:20
Bulma Blade Template For Laravel 5.7 Pagination
{{--
Laravel's default pagination html tags modifed to make Bulma CSS compatible paginator.
1. First run "php artisan vendor:publish --tag=laravel-pagination"
2. This command will place the views in the resources/views/vendor/pagination directory.
3. Replace text on "bootstrap-4.blade.php" with this code.
@derickito
derickito / PDFViewController.swift
Last active October 29, 2024 04:32
iOS PDFKit: How to add a highlight annotation
override func viewDidLoad() {
createMenu()
}
private func createMenu() {
let highlightItem = UIMenuItem(title: "Highlight", action: #selector(highlight(_:)))
UIMenuController.shared.menuItems = [highlightItem]
}
@objc private func highlight(_ sender: UIMenuController?) {