Skip to content

Instantly share code, notes, and snippets.

View lukywong's full-sized avatar

Luky Wong lukywong

View GitHub Profile
@caeb92
caeb92 / README.MD
Created February 22, 2020 21:24
PM2 fork and cluster mode configuration examples

Configure a new PM2 ecosytem

You must especificate the file JSON wich have the proper configuration for your app wich environment do you want to use (declared in your ecosystem file).

pm2 start ecosystem_cluster_mode.json --env production
pm2 save (Autostart your application when PM2 service is started/restarted)
pm2 ls (Shows PM2 runnings apps)
netstat -ntpl | grep pm2 (Filter running PM2 applications)

Flag --env

@seafooler
seafooler / manpath-wrong
Created December 19, 2017 12:52
Fix: "manpath: can't set the locale; make sure $LC_* and $LANG are correct"
## Problem
When login in, the shell prints:
```
manpath: can't set the locale; make sure $LC_* and $LANG are correct
```
## Solution
```
sudo locale-gen "en_US.UTF-8"
sudo dpkg-reconfigure locales
@JPvRiel
JPvRiel / journalctl_enable_persistent_storage.md
Last active January 24, 2024 20:23
Enable persistent storage for the systemd journal log

Enable persistent storage for the systemd journal log

Overview

The assumed default setting in /etc/systemd/journald.conf is Storage=auto which implies that systemd journaling will only persist the journal if the expected storage location is available. Otherwise, the journal data is stored in memory and lost between reboots. On Ubuntu 16.04, /var/log/journal does not exist by default. Create it to keep and query events from previous boots.

Considerations:

  • Syslog still provides the persistant log records for Ubuntu 16.04, so enabling persistant systemd journal logging does cause a level of duplicaiton.
  • There are sane defaults:
//go to https://jenkins/script and run
item = Jenkins.instance.getItemByFullName("job_name")
item.builds.each() { build ->
build.delete()
}
item.updateNextBuildNumber(1)
@brennanMKE
brennanMKE / hero.ts
Last active April 1, 2024 16:16
Example of Mongoose with TypeScript and MongoDb
import * as mongoose from 'mongoose';
export let Schema = mongoose.Schema;
export let ObjectId = mongoose.Schema.Types.ObjectId;
export let Mixed = mongoose.Schema.Types.Mixed;
export interface IHeroModel extends mongoose.Document {
name: string;
power: string;
@keijiro
keijiro / PbxModifier.cs
Created July 2, 2015 03:08
(Unity Xcode Manipulation API) An example which modifies compiler flags for a given source file.
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using System.IO;
public class PbxModifier
{
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
@keijiro
keijiro / 00_README.md
Last active April 6, 2022 07:26
About Xcode Manipulation API in Unity

Unity から出力される Xcode プロジェクトをカスタマイズする方法 - Xcode Manipulation API

Unity 5 には Xcode Manipulation API が標準で搭載されており、これを使うことで、Unity の出力する Xcode プロジェクトを比較的簡単にカスタマイズすることができます。

ここでは例として、Unity から出力される Xcode プロジェクトの Info.plist ファイルを書き換えてみます。

下にある XcodeProjectUpdater.cs がそれです。このファイルを Editor ディレクトリ下に放り込んでおきます。すると、ビルド時に Info.plist を書き換えて、“TestEntry” というキーに “Hello” という値を設定します。見たそのまんまのシンプルな内容です。

鍵となるのは UnityEditor.iOS.Xcode に用意されている PlistDocument と PBXProject です。これらのクラスを使うことで、plist ファイルや Xcode プロジェクトファイルの書き換えが簡単に行えるわけです。

@donnut
donnut / currying.md
Last active October 28, 2023 17:58
TypeScript and currying

TypeScript and currying

In functional programming you often want to apply a function partly. A simple example is a function add. It would be nice if we could use add like:

var res2 = add(1, 3); // => 4

var add10To = add(10);
var res = add10To(5); // => 15
@suissa
suissa / watermark.js
Last active June 12, 2023 10:07
Add watermark with Node.js and ffmpeg
var ffmpeg = require('ffmpeg');
try {
var process = new ffmpeg('example.mp4');
process.then(function (video) {
console.log('The video is ready to be processed');
var watermarkPath = 'watermark-suissa.png',
newFilepath = './video-com-watermark.mp4',
settings = {
position : "SE" // Position: NE NC NW SE SC SW C CE CW
@jhjguxin
jhjguxin / gpg-tour.md
Created July 19, 2013 08:18
GPG 加密解密简明教程 </br> 作者: riku / 本文采用CC BY-NC-SA 2.5协议 授权

GPG 加密解密简明教程

大家都知道,互联网上充斥着大量的明文传输方式,可以说绝对是不安全地带。那么,我们如何保证在不安全的互联网中更可靠的传输重要数据呢?个人认为最好的方式之一就是使用 GPG 工具进行加密。此文只是简单介绍了 GPG 的常规用法,重在推广和普及 GPG 加密工具,详细的使用请参见 GPG 手册。

名词解释

RSA / DSA / ElGamal : 是指加密算法

GPG :(全称 GnuPG ) 是一款非对称加密(PGP)的免费软件,非对称加密方式简单讲就是指用公钥加密文件,用私钥解密文件。如果你想给谁发送加密信息,首先你要得到他的公钥,然后通过该公钥加密后传给他,对方利用自已的私钥就可解密并读取文件了。