Skip to content

Instantly share code, notes, and snippets.

@jsfaint
jsfaint / str2IntArry.c
Created June 20, 2014 09:43
implement a fake standard lib function. atoi_fake()
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef unsigned char bool;
typedef unsigned short ushort;
typedef unsigned char uchar;
#define TRUE 1
/*
* Created by SharpDevelop.
* User: JS
* Date: 2008-10-11
* Time: 22:31
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Net.Mail;
@jsfaint
jsfaint / PKGBUILD
Created June 20, 2014 12:33
An ACPI handler, auto disable Speaker when headset plugin, enable Speaker when headset removed.
# Maintainer: Jason <jsfaint@gmail.com>
pkgname=headset_hotplug
pkgver=0.2
pkgrel=1
pkgdesc="Auto disable/enable Speaker when headset plugin/unplugin"
arch=('any')
license=("GPL")
source=("headset_hotplug" "headset_hotplug.sh")
@jsfaint
jsfaint / 99-intelbacklight.rules
Created June 20, 2014 12:36
A udev rules for laptop, set intel graphic card brightness.
ACTION=="change", SUBSYSTEM=="backlight", RUN+="/usr/sbin/intelbacklight.sh"
@jsfaint
jsfaint / ntfsutil.sh
Created November 16, 2014 13:13
Enable/Disable Mac build-in NTFS written. e.g.: ./ntfsutil.sh (m/u) /dev/disk2s1
#!/bin/bash
mount_disk()
{
sudo umount $disk
mkdir ~/Desktop/$diskname
sudo mount_ntfs -o rw,auto,nodev,nobrowse,noowners,noatime $disk ~/Desktop/$diskname
echo "Mount $disk to ~/Desktop/$diskname"
open ~/Desktop/$diskname
}
@jsfaint
jsfaint / create_ramdisk.sh
Created March 10, 2015 02:28
Create RAM Disk for OS X
#!/bin/bash
size=1024
usage() {
echo "$0: Create RAM Disk with given size(default is 1024MB)"
echo " e.g.: $0 512"
exit 1
}
@jsfaint
jsfaint / sys_proxy
Last active April 13, 2020 01:26
Set System Proxy for OS X
#!/bin/bash
wifi="Wi-Fi"
IP=127.0.0.1
PORT=7777
[[ $# -ne 1 ]] && echo "$0 http|pac|disable" && exit 1
flag=$1
function webproxy_set() {
@jsfaint
jsfaint / proxy
Created March 10, 2015 02:30
set proxy for command, e.g.: ./proxy vim
#!/bin/bash
proxy=127.0.0.1:7777
http_proxy=$proxy https_proxy=$proxy $@
@jsfaint
jsfaint / ipmi_channel.sh
Created March 10, 2015 02:41
Dump NCSI IP/Mac address using ipmitool
#!/bin/bash
channel_cmd="ipmitool channel info"
lan_cmd="ipmitool lan print"
function is_lan_channel()
{
local chan=$1
$channel_cmd $chan 2>&1 | grep LAN -q
if [[ $? -eq 0 ]]; then
return 1
@jsfaint
jsfaint / peach.c
Created March 17, 2015 08:11
桃子的问题
/*桃子的问题
1毛钱可以买一个桃子,每3个桃核可以换一个桃
问n元钱总共可以吃到多少个桃子
Author:jason
Date:2006.12.23
来源于群中的一个脑筋急转弯的问题。可用递归算法实现
*/
#include <stdio.h>;