Skip to content

Instantly share code, notes, and snippets.

@qdx
qdx / proxy_large_import.md
Created October 22, 2021 07:24
Tricky things when importing a lot of users into proxy

Before we have the performance issue of policies fixed, importing large amount of users requires the developer to implement a special import process. Basically the idea is to skip the policy syncs while importing, and trigger the policy sync only once after the import is finished.

  1. If you are using Create a person or Create or update a person endpoint for user imports, please switch to Create multiple persons endpoint instead first.
  2. To skip policy sync for an import, add skipSyncPolicies=true in the query string while calling Create multiple persons endpoint.
  3. To trigger the policy sync after import is done, we need to get and then patch all policies.
  4. Retrieve all policies by calling [Retrieve all policies](https://docs.proxy.com/api/manage#operation/getP
@qdx
qdx / gist:3215f4b14ef203dfaf7654ce3ed01c23
Last active November 22, 2020 08:39 — forked from Arakade/gist:9dd844c2f9c10e97e3d0
Call from OnDrawGizmos() to draw text at Unity3D glocal position in Editor
static void drawString(string text, Vector3 worldPos, Color? colour = null) {
UnityEditor.Handles.BeginGUI();
if (colour.HasValue) GUI.color = colour.Value;
var view = UnityEditor.SceneView.currentDrawingSceneView;
Vector3 screenPos = view.camera.WorldToScreenPoint(worldPos);
Vector2 size = GUI.skin.label.CalcSize(new GUIContent(text));
GUI.Label(new Rect(screenPos.x - (size.x / 2), -screenPos.y + view.position.height + 4, size.x, size.y), text);
UnityEditor.Handles.EndGUI();
}
@qdx
qdx / gold_mining_problem.txt
Created June 22, 2017 00:17
Gold mining problem
You manage a gold mining facility, to simplify mining, lets say each mine has multiple levels that gives you different profit.
For example, you may have 4 gold mines, let's call them a, b, c, d.
Each of them has a couple levels:
a: 1 level
b: 2 levels
c: 1 level
d: 4 levels
and each level have gives you different profit if you mine it:
a: 2
b: 8, 4
import scala.util.continuations._
class Generator[A] extends Iterator[A] with (A => Unit @ suspendable) {
private var a: Option[A] = None
private var k: Option[Unit => Unit] = None
def next = {
val a0 = a.get
val k0 = k.get
a = None
@qdx
qdx / init.sh
Last active December 28, 2015 22:59
# for this thing to work, you have to manually setup ssh identity and add it to
# bitbucket first(in order to clone vimwiki)
cd ~/
# install git
sudo apt-get install git
# get gitconfig
curl https://gist.github.com/qdx/7554766/raw/ed205920a624ac4c7290b3fd4c7841ba6e47c8f5/.gitconfig -o .gitconfig
@qdx
qdx / .vimrc.bundles.local
Last active December 28, 2015 22:59
my local bundles that add function based on spf13
Bundle 'mattn/emmet-vim'
Bundle 'vim-scripts/vimwiki'
Bundle 'mbbill/fencview'
@qdx
qdx / .vimrc.local
Last active December 28, 2015 22:59
my local vimrc that add function based on spf13 distribution of vim
" Maintainer: DeXin Qi<qdxzzz@gmail.com>
" set Encoding
set encoding=utf-8
set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
"set langmenu=zh_CN.UTF-8
"language message zh_CN.UTF-8
"source $VIMRUNTIME/delmenu.vim
"source $VIMRUNTIME/menu.vim
@qdx
qdx / .gitconfig
Last active December 28, 2015 20:08
[user]
name = qdx
email = qdxzzz@gmail.com
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
lg = !"git lg1"
@qdx
qdx / gist:6783525
Created October 1, 2013 19:12
my vimrc for ubuntu
" Maintainer: DeXin Qi<qdxzzz@gmail.com>
" Last change: 2011 Oct 14
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
" @from example vimrc file
if(str.length < 60) str else str.substring(0,60)