Skip to content

Instantly share code, notes, and snippets.

@shichao-an
shichao-an / gist:8992bd6e03582dc474f5d86b6b2aa440
Last active March 29, 2019 02:43 — forked from psayre23/gist:c30a821239f4818b0709
Runtime Complexity of Java Collections
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
@shichao-an
shichao-an / tmpdownloads.plist
Created April 24, 2018 00:56
Create a Downloads directory on macOS startup/login
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.loginscript</string>
<key>ProgramArguments</key>
<array>
<string>/bin/mkdir</string>
<string>-p</string>
<string>/private/tmp/Downloads</string>
</array>
@shichao-an
shichao-an / common-password
Created February 4, 2015 00:07
/etc/pam.d/common-password
#
# /etc/pam.d/common-password - password-related modules common to all services
#
# This file is included from other service-specific PAM config files,
# and should contain a list of modules that define the services to be
# used to change user passwords. The default is pam_unix.
# Explanation of pam_unix options:
#
# The "sha512" option enables salted SHA512 passwords. Without this option,
@shichao-an
shichao-an / ebs_lvm.sh
Created August 26, 2014 05:21
Create LVM on EBS
#!/bin/bash
ebs_disk="/dev/xvdf"
ebs_partition="/dev/xvdf1"
vg_name="vg"
pv_name="pv1"
mount_point="/mnt"
# Create a primary partition on $ebs_disk using all space
@shichao-an
shichao-an / ldap_disable_bind_anon.ldif
Created February 3, 2015 19:53
Ubuntu and LDAP: force authentication during a bind request
# ldapadd -Y EXTERNAL -H ldapi:/// -f ldap_disable_bind_anon.ldif
dn: cn=config
changetype: modify
add: olcDisallows
olcDisallows: bind_anon
dn: cn=config
changetype: modify
add: olcRequires
olcRequires: authc
@shichao-an
shichao-an / companies.txt
Last active May 18, 2017 06:11
Popular companies for coding interviews (LeetCode)
Amazon
Microsoft
Facebook
Google
LinkedIn
Twitter
Apple
Zenefits
Uber
Airbnb
@shichao-an
shichao-an / evdn3.md
Last active March 10, 2017 07:16
English Vocabulary Digest Note 3
  • cringe (vi.) 畏缩; 感到难堪
  • antics (n.) 滑稽的举止
  • nuts and bolts (n.) 基础部分; (adj.) 有关具体细节的
  • innuendo (n.) 暗示; 影射
  • demoralize (vt.) 使泄气
  • endearment (n.) 爱慕
  • outnumber (vt.) 在数量上超过
  • drool (vi.) 淌口水; 垂涎
  • chastise (vt.) 责备
  • whine (vt.) 哭喊
@shichao-an
shichao-an / evdn2.md
Last active June 5, 2016 05:26
English Vocabulary Digest Note 2
  • noob (n.) 新手 (a person who is inexperienced in a particular sphere or activity, especially computing or the use of the Internet.)
  • calamitous (adj.) 灾难性的
  • swamp (vt.) 淹没; 使…应接不暇; 使…人满为患
  • layman/layperson (n.) (non-expert) 外行
  • necessitate (vt.) 使成为必要
  • warrant (vt.) 证明…正当 (justify); 使成为必要 (necessitate); 为...作担保
  • instrumental (adj.) to be instrumental in [something]/doing [something] 对某事物/对做某事起重要作用 (to have important role)
  • stagnant (adj.) (sluggish) 停滞的; 不景气的
  • reap (vt.) 获得
  • weigh (vt.) 权衡; 衡量 (vt.) 有影响 (have influence) (exp. to weigh heavily/very little with [somebody] 对某人影响很大/很小)
#include <stdio.h>
#include <stdlib.h>
#define test(x) ({ \
typeof(x) _x = (x); \
_x += 1; \
_x; \
})
int main(int argc, char* argv[])
@shichao-an
shichao-an / bit_field.c
Created April 27, 2016 05:50
Bit fields
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char * argv[])
{
struct
{
bool a: 1;
bool b: 1;