Skip to content

Instantly share code, notes, and snippets.

@yrong
yrong / customEdge.html
Created November 12, 2019 13:33 — forked from davidjgraph/customEdge.html
Custom edge example for mxGraph
<!--
$Id: markers.html,v 1.4 2013/10/28 08:44:55 gaudenz Exp $
Copyright (c) 2006-2014, JGraph Ltd
Demonstrates creating a custom edge in mxGraph
-->
<html>
<head>
<title>Custom edge example for mxGraph</title>
@yrong
yrong / install.ps1
Created November 1, 2019 08:24
install node&pm2 and make app as service
write-host "check administator rights"
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
write-Warning "This setup needs admin permissions. Please run this file as admin."
exit
}
write-host "check os and powershell"
if (-NOT ([Environment]::Is64BitProcess))
{
@yrong
yrong / pivot.js
Created August 31, 2019 13:25 — forked from parshap/pivot.js
Find pivot index
// Return the "pivot index" of the given array of numbers. The pivot index is
// the index where the sum of the numbers on the left is equal to the sum of
// the numbers on the right.
function pivot(numbers) {
validateInput(numbers);
// Find a pivot index by testing each index
for (var i = 0; i < numbers.length; i++) {
var leftSum = sum(numbers.slice(0, i));
var rightSum = sum(numbers.slice(i + 1));
package main
import (
"bytes"
"flag"
"fmt"
"log"
"net/http"
"net/url"
"runtime"
@yrong
yrong / choco_installer.ps1
Created December 21, 2018 09:33
choco installer
### CONFIGURATION
### require administator rights
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
write-Warning "This setup needs admin permissions. Please run this file as admin."
break
}
@yrong
yrong / install_python.ps1
Created December 17, 2018 07:59 — forked from carlosfunk/install_python.ps1
Powershell scripts for setting up a Python environment under Windows
# To run this file you will need to open Powershell as administrator and first run:
# Set-ExecutionPolicy Unrestricted
# Then source this script by running:
# . .\install_python.ps1
$save_dir=Resolve-Path ~/Downloads
$project_dir = "C:\Projects"
$virtualenv_dir = $project_dir + "\virtualenvs"
$client = New-Object System.Net.WebClient
@yrong
yrong / nodejs_installer.ps1
Created November 26, 2018 09:21 — forked from nweldev/nodejs_installer.ps1
Powershell script installing nodejs (with git) and some npm packages
write-host "`n ## NODEJS INSTALLER ## `n"
### CONFIGURATION
# nodejs
$version = "4.4.7-x64"
$url = "https://nodejs.org/dist/latest-v4.x/node-v$version.msi"
# git
$git_version = "2.9.2"
@yrong
yrong / postgresql.py
Created July 30, 2018 01:06 — forked from robertsosinski/postgresql.py
DataDog script for collecting PostgreSQL stats
# Create the datadog user with select only permissions:
# CREATE USER datadog WITH PASSWORD '<complex_password>';
#
# Grant select permissions on a table or view that you want to monitor:
# GRANT SELECT ON <schema>.<table> TO datadog;
#
# Grant permissions for a specific column on a table or view that you want to monitor:
# GRANT SELECT (id, name) ON <schema>.<table> TO datadog;
#
# Let non-superusers look at pg_stat_activity in a read-only fashon.
@yrong
yrong / multiple_select.go
Created July 13, 2018 08:31
multiple select
func main(){
var n int = 10
var chs = make([]chan int, n)
var worker = func(n int, c chan int){
for i:=0;i<n;i++{
c<-i
}
close(c)
}
@yrong
yrong / observer.go
Created July 6, 2018 04:16
observer.go
// Package main serves as an example application that makes use of the observer pattern.
package main
import (
"fmt"
"time"
)
type (
// Event defines an indication of a point-in-time occurrence.