Skip to content

Instantly share code, notes, and snippets.

View ezirmusitua's full-sized avatar
🎯
Focusing

ezirmusitua ezirmusitua

🎯
Focusing
View GitHub Profile
@ezirmusitua
ezirmusitua / pull-rebase.md
Created November 1, 2019 13:03
push --rebase [set git pull --rebase in Visual Studio] #IDE

Team Explorer/Home/Settings/Global Settings[Repository Settings]/Rebase local branch when pulling

@ezirmusitua
ezirmusitua / change-permission-ownership.sh
Created October 17, 2019 02:11
Change directory permissions & ownership [change directory permissions & ownership in linux shell] #shell
sudo chown -R $USER /path/to/directory
@ezirmusitua
ezirmusitua / delete-from-array-field.js
Created October 17, 2019 02:07
Delete elements from array field [delete elements from array field in mongodb] #mongodb #javascript
db.Store.update({}, {$pull: {vegetables: {$in: ['v1', 'v2']}, fruits: 'f1'}}, {multi: true})
@ezirmusitua
ezirmusitua / rmrf.ps1
Created October 4, 2019 04:42
equivalent of rmrf in powershell [equivalent of rmrf in powershell] #powershell #shell
rm C:\path\to\delete -r -fo
@ezirmusitua
ezirmusitua / use-root-state.js
Created September 20, 2019 12:18
Use root action [Use root action with module dispatch in vuex] #vue #javascript
// stores.js
const moduleA = {
state: {},
mutations: {},
actions: {
action2({dispatch) {
dispatch('action1', null, {root: true}); // add {root:true} in dispatch method
}
},
getters: {}
@ezirmusitua
ezirmusitua / fix-ERR_SSL_PROTOCOL_ERROR.sh
Created September 20, 2019 11:54
Fix ERR_SSL_PROTOCOL_ERROR [Fix ERR_SSL_PROTOCOL_ERROR In Nginx] #nginx
# Ensure The Write Nginx Config Correctly
server {
listen 443 ssl; # ssl is necessary
server_name www.example.com;
ssl_certificate www.example.com.crt;
ssl_certificate_key www.example.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
...
}
@ezirmusitua
ezirmusitua / start-up-with-system.md
Created September 10, 2019 21:51
[Start up with system] start up with system #windows

下载 NSSM

Download

添加自启动

win + R -> cmd

cd \path\to\nssm.exe
nssm install <start-up-service>
@ezirmusitua
ezirmusitua / param-action.cs
Created September 10, 2019 21:46
[Use Action as parameter with unlimited parameters] #C#
// 不加参数的 Action 参数可以传拥有任意数目参数的函数
protected void udpCommand(Action command)
{
while(!linkDownFail)
{
try
{
command();
break;
}
@ezirmusitua
ezirmusitua / simple-template.js
Last active September 10, 2019 21:41
[Template function] Simple template function using js template string #node #template
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
function template(strings, ...keys) {
return ((...values) => {
const dict = values[values.length - 1] || {};
const result = [strings[0]];
keys.forEach((key, i) => {
const value = Number.isInteger(key) ? values[key] : dict[key];
result.push(value, strings[i + 1]);
});
@ezirmusitua
ezirmusitua / use-expr-operator.js
Created August 16, 2019 13:39
[MongoDB Query: `$expr` operator] Mongodb query operator `$expr` usage #mongodb
// https://docs.mongodb.com/manual/reference/operator/query/expr/#op._S_expr
//// $expr can build query expressions that compare fields from the same document in a $match stage.
////// Compare Two Fields from A Single Document
////// The following operation uses $expr to find documents where the spent amount exceeds the budget
db.monthlyBudget.find( { $expr: { $gt: [ "$spent" , "$budget" ] } } )
////// Using $expr With Conditional Statements
////// The following operation uses $expr with $cond to mimic a conditional statement. It finds documents where the price is less than 5 after the applied discounts.
db.supplies.find( {