Skip to content

Instantly share code, notes, and snippets.

View rickyngk's full-sized avatar

Ricky.ngk rickyngk

  • Vietnamworks
  • Vietnam
View GitHub Profile
@rickyngk
rickyngk / Dockerfile
Created April 8, 2022 17:32
Puppeteer for Apple M1
FROM node:12-stretch
RUN apt-get update && \
apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget dumb-init
RUN apt-get install chromium -y
@rickyngk
rickyngk / gist:1402c0650249db0a0b20d7878fecc786
Created January 26, 2019 18:22
OpenResty + Kaltura vod + Kaltura secure token | Nginx config local mode sample
worker_processes auto;
events {
use epoll;
}
http {
log_format main '$remote_addr $remote_user [$time_local] "$request" '
'$status "$http_referer" "$http_user_agent"';
@rickyngk
rickyngk / Dockerfile
Created January 26, 2019 18:19
OpenResty + Kaltura vod + Kaltura secure token
FROM alpine:3.8 AS base_image
FROM base_image AS build
RUN apk add --no-cache curl build-base openssl openssl-dev zlib-dev linux-headers pcre-dev ffmpeg ffmpeg-dev perl
RUN mkdir openresty nginx-vod-module nginx-secure-token-module
ENV OPENRESTY_VERSION 1.13.6.1
ENV VOD_MODULE_VERSION 1.24
ENV VOD_SECURE_TOKEN_MODULE_VERSION 1.3
import java.util.ArrayList;
import java.util.Arrays;
public class MergeSample {
public static int fPoints(String phrase, String keywords) {
keywords = keywords.toLowerCase().trim().replaceAll(" +", " ");
phrase = phrase.toLowerCase().trim().replaceAll(" +", " ");
// matching all phrase
@rickyngk
rickyngk / hosts.allow
Created September 21, 2018 07:00
Sample libwrap config
# /etc/hosts.allow: list of hosts that are allowed to access the system.
# See the manual pages hosts_access(5) and hosts_options(5).
#
# Example: ALL: LOCAL @some_netgroup
# ALL: .foobar.edu EXCEPT terminalserver.foobar.edu
#
# If you're going to protect the portmapper use the name "rpcbind" for the
# daemon name. See rpcbind(8) and rpc.mountd(8) for further information.
#
@rickyngk
rickyngk / dante.conf
Created September 21, 2018 06:55
basic Dante SOCK5 proxy config
logoutput: /var/log/socks.log
internal.protocol: ipv4 ipv6
internal: eth0 port = 1080
external.protocol: ipv4 ipv6
external: eth0
external.rotation: same-same
@rickyngk
rickyngk / export.py
Created May 17, 2017 15:18
Export XCode string files to excel
import fnmatch
import os
import xlsxwriter
import collections
texts = {}
for root, dirnames, filenames in os.walk('./YourAwesomeProject/'):
for filename in fnmatch.filter(filenames, '*.strings'):
dirs = root.split("/")
@rickyngk
rickyngk / 2d-sprite.swift
Last active May 5, 2016 08:10
2d-sprite in short
var regs:[UIImage] = [UIImage]();
let src:UIImage = UIImage(named:fileName)!
let ci_src:CIImage = CIImage.init(image: src)!
let context = CIContext(options:nil)
let regionW:Int = Int(Int(src.size.width)/cols)
let regionH:Int = Int(Int(src.size.height)/rows)
var x = 0, y = 0
for _ in 1 … rows {
@rickyngk
rickyngk / ViewController.swift
Last active May 5, 2016 08:13
2d sprite animation with swift
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var animView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
animView.setAnimSpritesheet("player.png", rows: 3, cols: 7, fps: 12)
animView.animationRepeatCount = 0;
public class MainActivity extends AppCompatActivity
implements SampleViewModel.ISampleViewModelEventListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
binding.setViewModel(new SampleViewModel(this, this));
}