Skip to content

Instantly share code, notes, and snippets.

@kaiix
kaiix / gist:4070967
Created November 14, 2012 08:20
Add dotted/dashed border to a UITableViewCell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
if (!cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
}
import inspect
from functools import wraps
import openai
def generate_code(signature, docstring):
init_prompt = "You are a Python expert who can implement the given function."
definition = f"def {signature}"
prompt = f"Read this incomplete Python code:\n```python\n{definition}\n```"
@kaiix
kaiix / mongodb.logrotate
Last active December 30, 2020 03:55
logrotate mongodb log
/var/log/mongodb/mongod.log {
hourly
missingok
rotate 5
compress
delaycompress
notifempty
create 0640 mongodb mongodb
sharedscripts
postrotate
#!/bin/bash
set -e
SSH_DIR="${HOME}/.ssh"
SSH_CONFIG_BASE64=`curl -s http://vault.in.ein.plus/keys/ein-ci`
mkdir -p "${SSH_DIR}"
chmod 0700 "${SSH_DIR}"
@kaiix
kaiix / kenter.sh
Last active December 27, 2018 03:50
__kubectl_init_completion()
{
COMPREPLY=()
_get_comp_words_by_ref "$@" cur prev words cword
}
__kubectl_get_pod()
{
if declare -F _init_completion >/dev/null 2>&1; then
_init_completion -s || return
@kaiix
kaiix / GlossGradientButton.h
Created May 28, 2012 11:55
Gloss gradients button for ios
//
// GlossGradientButton.h
// iOS version of gloss gradients button
// original version for Mac OSX http://cocoawithlove.com/2008/09/drawing-gloss-gradients-in-coregraphics.html
//
#import <UIKit/UIKit.h>
@interface GlossGradientButton : UIButton {
UIColor *buttonColor_;
import csv
import os
import plistlib
def parse_safari_reading_list_plist():
plist = plistlib.load(
open(os.path.expanduser('~/Library/Safari/Bookmarks.plist'), 'rb'))
items = []
@kaiix
kaiix / Netfilter-IPTables-Diagrams.md
Created February 28, 2018 08:51 — forked from nerdalert/Netfilter-IPTables-Diagrams.md
Linux NetFilter, IP Tables and Conntrack Diagrams

Linux NetFilter, IP Tables and Conntrack Diagrams

IPTABLES TABLES and CHAINS

IPTables has the following 4 built-in tables.

1) Filter Table

Filter is default table for iptables. So, if you don’t define you own table, you’ll be using filter table. Iptables’s filter table has the following built-in chains.

@kaiix
kaiix / try.c
Created September 23, 2016 09:08
try/catch with setjmp
#include <unistd.h>
#include <stdio.h>
#include <setjmp.h>
#include <signal.h>
jmp_buf j;
void try()
{
printf("call try\n");
@kaiix
kaiix / EC2.md
Last active February 3, 2016 04:24 — forked from kkc/EC2.md
EC2 settings

EC2 相關設定

記憶體

  1. 設定swap(預設為60, 當系統使用到超過40% memory, 就會嘗試使用swap)

    sysctl -w vm.swappiness=0   # from 60 -> 0