Instantly share code, notes, and snippets.

Shichao An shichao-an

View GitHub Profile
View gist:8992bd6e03582dc474f5d86b6b2aa440
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
View tmpdownloads.plist
<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>
View evdn3.md
  • cringe (vi.) 畏缩; 感到难堪
  • antics (n.) 滑稽的举止
  • nuts and bolts (n.) 基础部分; (adj.) 有关具体细节的
  • innuendo (n.) 暗示; 影射
  • demoralize (vt.) 使泄气
  • endearment (n.) 爱慕
  • outnumber (vt.) 在数量上超过
  • drool (vi.) 淌口水; 垂涎
  • chastise (vt.) 责备
  • whine (vt.) 哭喊
View typeof.c
#include <stdio.h>
#include <stdlib.h>
#define test(x) ({ \
typeof(x) _x = (x); \
_x += 1; \
_x; \
})
int main(int argc, char* argv[])
View bit_field.c
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char * argv[])
{
struct
{
bool a: 1;
bool b: 1;
View flexible_array_member.c
#include <stdio.h>
#include <stdlib.h>
typedef struct string
{
int length;
char chars[];
} string;
int main(int argc, char * argv[])
View struct_offset.c
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
int x;
short y[3];
long long z;
} data_t;
View array-params.c
#include <stdio.h>
#include <stdlib.h>
/* the array name by default is a pointer to its first element,
* similar to test2
*/
void test1(int len, int x[])
{
int i;
for (i = 0; i < len; i++)
View sbcsucks.sh
#!/usr/bin/env bash
# Check if SBC is stable and send a notification
OUTSIDE_HOST="${1:-8.8.8.8}"
PING_COUNT=15
PING_TIMEOUT=15
PING_INTERVAL=0.5
ASC_MBP="10.0.1.10"
STATUS="unknown"
View evdn2.md
  • 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] 对某人影响很大/很小)