Skip to content

Instantly share code, notes, and snippets.

View skyscribe's full-sized avatar
🏠
Available

Fei skyscribe

🏠
Available
View GitHub Profile
@skyscribe
skyscribe / inxi.sh
Created November 1, 2012 01:19
inxi installation
mkdir ~/bin
cd ~/bin
wget https://inxi.googlecode.com/svn/trunk/inxi
chmod +x inxi
@skyscribe
skyscribe / .gdbinit
Created October 30, 2012 03:04
GDB init file to print STL containers and data members
#
# STL GDB evaluators/views/utilities - 1.03
#
# The new GDB commands:
# are entirely non instrumental
# do not depend on any "inline"(s) - e.g. size(), [], etc
# are extremely tolerant to debugger settings
#
# This file should be "included" in .gdbinit as following:
# source stl-views.gdb or just paste it into your .gdbinit file
@skyscribe
skyscribe / CMakeLists.txt
Created August 18, 2012 02:00
C++11 examples
cmake_minimum_required(VERSION 2.6)
if (use_llvm)
add_definitions(-std=c++11)
set(clang_version 3.1)
##llvm
set(CMAKE_CXX_COMPILER clang++)
#set(CMAKE_CXX_FLAGS "-std=c++11")
set(CMAKE_C_COMPILER clang)
set(CMAKE_AR llvm-ar-${clang_version})
@skyscribe
skyscribe / Makefile
Created August 14, 2012 14:45
Santa problem showing STM
santa: santa.hs
ghc $^ -package stm -o $@
run: santa
./santa
clean:
rm santa.hi santa.o santa
@skyscribe
skyscribe / cloc_folder.bash
Created August 14, 2012 01:02
Filter cloc result for a certain folder and get statistic information
#!/bin/bash
for folder in `ls -l | grep "^d" | awk '{print $NF}'`;do
echo "counting lines for folder $folder" >> cloc.txt;
cloc.pl $folder >> cloc.txt;
done
filterCloc.awk cloc.txt > cloc_summary.txt
@skyscribe
skyscribe / AnonyousHandle.hs
Created April 1, 2012 03:30
New haskell exception ambiguous type issue in real word example code BetterPredicate.hs
import Control.Exception (bracket, handle, SomeException)
import System.IO (IOMode(..), hClose, hFileSize, openFile)
{-- snippet getFileSize --}
-- To work around the code that doesn't work in Haskell 6.10
-- Control.Exception is changed to allow ploymophism such that
-- handle (\_ -> return Nothing) doesn't compile
hdl::SomeException -> IO (Maybe a)
hdl _ = return Nothing
@skyscribe
skyscribe / Sheep.hs
Created March 23, 2012 09:31
MonadSheep
data Sheep = SheepCreator String (Sheep, Sheep) | NONE
deriving Show
father:: Sheep -> Maybe Sheep
father (SheepCreator name (NONE, _)) = Nothing
father (SheepCreator name (f, _)) = Just f
mother:: Sheep -> Maybe Sheep
mother (SheepCreator name (_, NONE)) = Nothing
mother (SheepCreator name (_, m)) = Just m
@skyscribe
skyscribe / generate_sed.sh
Created March 3, 2012 03:33
generate gcc tags from header
#!/bin/bash
if [ $# -eq 0 ];then
dir=.
else
dir=$1
fi
#Substitute scripts
cat > .edit.sed <<- EOF
s/\b_GLIBCXX_BEGIN_NAMESPACE\b\s*\(\s*(\w+)\s*\)/namespace \1{/g
@skyscribe
skyscribe / aggregate_records_per_5_min.awk
Created March 1, 2012 02:54
aggregate records by awk - calculate average per 5 minutes
cat $repFile | cut -d "|" -f2-5 | egrep "[0-9]\|$" | grep -v "None" | sort | gawk '
function getAdjustedTime(startTime)
{
split(startTime, splits, ":");
return sprintf("%s:%02d", splits[1], (int(splits[2]/5) * 5))
}
BEGIN{
FS="|";
printf("%20s | %6s | %6s | %3s | %3s\n", "TIME", "COUNT", "DUR", "AVG", "MAX")
printf("-------------------------------------------------------------\n")
@skyscribe
skyscribe / netsnmp_view_destroy.c
Created February 29, 2012 13:18
netsnmp_view_destroy
void
netsnmp_view_destroy(struct vacm_viewEntry **head, const char *viewName,
oid * viewSubtree, size_t viewSubtreeLen)
{
struct vacm_viewEntry *vp, *lastvp = NULL;
if ((*head) && !strcmp((*head)->viewName + 1, viewName)
&& (*head)->viewSubtreeLen == viewSubtreeLen
&& !memcmp((char *) (*head)->viewSubtree, (char *) viewSubtree,
viewSubtreeLen * sizeof(oid))) {