Skip to content

Instantly share code, notes, and snippets.

@john-science
john-science / gzip_files_in_python.md
Last active May 27, 2021 16:47
Reading & Writing GZIP Files Faster in Python

Reading & Writing GZIP Files in Python

I have been testing various ways to read and write text files with GZIP in Python. There were a lot of uninteresting results, but there were two I thought were worth sharing.

Writing GZIP files

If you have a big list of strings to write to a file, you might be tempted to do:

f = gzip.open(out_path, 'wb')

for line in lines:

@Jimmy-Xu
Jimmy-Xu / shadowsocks_privoxy_tsocks.md
Last active April 29, 2022 15:00
shadowsocks+privoxy/tsocks

shadowsocks + privoxy/tsocks

  • shadowsocks: service, socks proxy
  • privoxy: service, convert socks proxy to http proxy
  • tsocks: tool, use socks proxy for any command line

Usage

tested under ubuntu14.04

@eonist
eonist / TranslucentWin.swift
Created January 27, 2016 14:09
Translucent NSWindow Example
class TranslucentWin:NSWindow, NSApplicationDelegate, NSWindowDelegate{
/**
*
*/
override init(contentRect: NSRect, styleMask aStyle: Int, backing bufferingType: NSBackingStoreType, `defer` flag: Bool) {
super.init(contentRect: Win.sizeRect, styleMask: NSTitledWindowMask|NSResizableWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask|NSFullSizeContentViewWindowMask, backing: NSBackingStoreType.Buffered, `defer`: false)
self.contentView!.wantsLayer = true;/*this can and is set in the view*/
self.backgroundColor = NSColor.greenColor().alpha(0.2)
self.opaque = false
self.makeKeyAndOrderFront(nil)//moves the window to the front
@yiwenl
yiwenl / hsv2rgb
Last active April 14, 2024 17:35
GLSL Color Coversions
vec3 hsv2rgb(vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
@paulirish
paulirish / what-forces-layout.md
Last active May 21, 2024 09:11
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@fffaraz
fffaraz / exec.md
Last active March 1, 2021 12:23
execl, execlp, execle, execv, execvp, execvpe
- e p
l execl execle execlp
v execv execve execvp

  • int execl(char const *path, char const *arg0, ...);
  • int execle(char const *path, char const *arg0, ..., char const *envp[]);
@Ulu2005
Ulu2005 / cmu_course.md
Created July 13, 2015 21:45
CMU CS Course Info

#CMU Course Info 整理自一亩三分地

##08722 – Data Structurefor application programmers 这门课主要是开给EBIZ和MISM的,在MISM那边的课号是95772. 但是很多ECE, INI的同学,以及咱ME转CS帮都在上这门课。这门课只有半学期,一共6个credits,相当于1.5学分。内容非常基础,但是我觉得帮助挺大的,对于非CS科班出身想转CS的同学非常建议上一下, 基础越弱收获越大,要是基础比较硬的话就不用上了。LZ上的其它CS的课几乎都是各种牛校的PHD出身,这门课的老师好像都没有PHD学位,肯定没法去上15的课,但是讲课挺用心,讲的也很清楚。讲课这东西真的不是老师自己越牛就讲的越好。尤其数据结构这种比较基础的内容。这门课从最简单的内容讲起,包括array, arraylist, linked list, stack, queue,sorting(bubble, selection, insertion, merge, quick, heap), hashTable, hashMap,hashSet, BST, TreeMap, TreeSet, Huffman coding, Heap. 每周一次quiz, lab, homework。讲的时候内容都围绕Java Collection 来讲,还涉及与collection有关的comparator, iterator 等内容。这门课完全就是针对面试的,作业要求先手写代码(虽然大部分时候都是先ECLIPSE敲好再抄到纸上的)。

6次homework,前面的非常简单,后面稍微麻烦一点,难度都不大,就是让你去熟悉这些数据结构能自己implement,也能用JAVA COLLECTION。

  1. 自己implement 一个 arraylist 实现各种要求
  2. Queue, stack 的implement和应用
<a class="question_link" target="_blank" href="/question/30746665/answer/49332475">会写 Parser、Tokenizer 是什么水平?</a><br/><br/>大多数编译原理书前100页的内容,说明大学听了一半左右的编译原理课,通俗地说,写了这个只能证明你不是个棒槌。<br><br><br>所以其实你更应该关心不会tokenizer和parser是什么水平。
<span class="answer-date-link-wrap">
<a class="answer-date-link last_updated meta-item" data-tip="s$t$发布于 2015-05-29" target="_blank" href="/question/30746665/answer/49332475">编辑于 2015-05-29</a>
</span>
<hr/><a class="question_link" target="_blank" href="/question/30703519/answer/49150834">王垠到底对 winter 做了什么?</a><br/><br/>你可以理解为是路边看到一坨**,忍不住想去一脚踩爆它的心态。(虽然我知道这么做无聊而且会沾一脚)<br><br>想了想,可能还有一点觉得他的粉丝很可怜的,想让他们停止吃**的心态吧,虽然我知道"然而没卵用"。<br><br>回到题主的问题,要问做了什么,那就是“他是**,还碰巧被我看到了”,这样的事情,简直无法被饶恕。
@itfrombit
itfrombit / gist:2075934dabf9a378b628
Created December 7, 2014 23:42
excerpt to programmatically create a menu in OS X
NSMenu* menubar = [NSMenu new];
NSMenuItem* appMenuItem = [NSMenuItem new];
[menubar addItem:appMenuItem];
[NSApp setMainMenu:menubar];
NSMenu* appMenu = [NSMenu new];
NSString* toggleFullScreenTitle = @"Toggle Full Screen";
@xhacker
xhacker / emoji.plist
Last active October 26, 2023 15:59
/System/Library/LinguisticData/RequiredAssets_zh.bundle/AssetData/emoji.plist in OS X 10.11 Copyright (C) Apple Inc.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>0</key>
<dict>
<key>emoji</key>
<array>
<string>0⃣️</string>
</array>