Skip to content

Instantly share code, notes, and snippets.

View owlfox's full-sized avatar
🏠
Working from home

Chen Zeren owlfox

🏠
Working from home
View GitHub Profile
@owlfox
owlfox / 6.8.c
Created August 23, 2015 03:37
CSAPP_6.8
#include <stdio.h>
#define SIZE 4
int summarray3d(int a[SIZE][SIZE][SIZE], int size)
{
int i, j, k, sum=0;
for(i=0;i<size;i++){
for(j=0;j<size;j++){
for(k=0;k<size;k++){
sum +=a[k][j][i];
printf("i:%2d,j:%2d,k:%2d, add:%p\n", i,j,k,&a[k][i][j]);
@owlfox
owlfox / quiz2.c
Last active August 29, 2015 14:27
Summer 2015 part2 Day3 quiz2, about reentrancy
#include <stdio.h>
#include <string.h>
int main(void)
{
char test[80], blah[80];
char *sep = "\\/:;=-";
char *word, *phrase, *brkt, *brkb;
strcpy(test, "This;is.a:test:of=the/string\\tokenizer-function.");
//Note strtok is obsoleted and not reentrant
@owlfox
owlfox / quiz2_tjc_version.c
Last active August 29, 2015 14:28
Summer 2015 part2 Day3 quiz2, about reentrancy, should add some mechanism to prevent out-of-boundary access...?
#include <stdio.h>
#include <string.h>
//wrapper function of strtok
/*strIn, can be NULL, then the result output will use lastState to manipulate */
char* strtok_tj_r(char* restrict strIn, const char* restrict tokens, char** restrict lastState)
{
char* result;
if(strIn!=NULL){
result = strtok(strIn,tokens);//the string has been modified by strok with token char replace by eof
@owlfox
owlfox / showi.c
Created November 19, 2015 02:35
Show hex, bin, unsigned, signed content of a integer. *This is the helper program modified from code from CSAPP website.
/* Display value of fixed point numbers */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* Extract hex/decimal/or float value from string */
static int get_num_val(char *sval, unsigned *valp) {
char *endp;
/* See if it's an integer or floating point */
int isbinary = 0;
#include <stdio.h>
#include <stdlib.h>
/* forward declaration */
typedef struct object Object;
typedef int (*func_t)(Object *);
struct object {
int a, b;
func_t add, sub;
A good commit message looks like this:
Header line: explaining the commit in one line
Body of commit message is a few lines of text, explaining things
in more detail, possibly giving some background about the issue
being fixed, etc etc.
The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
@owlfox
owlfox / tmux-cheatsheet.markdown
Created March 30, 2017 02:27 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
import java.nio.file.Files
import java.nio.file.Path
def getTempDirectory(prefix:String):String = {
val path = Files.createTempDirectory(prefix)
path.toString
}
@owlfox
owlfox / check_ntp.ps1
Created January 18, 2018 23:14
Check if ntp service running and try to start it in powershell, if failed prompt!
$sname="w32time"
#check if the service running
if((Get-service $sname | Where-Object {$_.status -eq "running"} ) -eq $Null){
#Not Running, restart it
Stop-service $sname
Start-service $sname
}
sleep 30

The Skills Poor Programmers Lack

A friend and I had a discussion about the basic skills that are often lacking in experienced programmers. How can a programmer work for ten or twenty years and never learn to write good code? So often they need close supervision to ensure they go down the right path, and they can never be trusted to take technical leadership on larger tasks. It seems they are just good enough to get by in their job, but they never become effective.

We thought about our experiences and came up with three fundamental skills that we find are most often missing. Note that these are not skills which take a considerable amount of talent or unique insight. Nor are they "trends" or "frameworks" to help you get a new job. They are basic fundamentals which are prerequisites to being a successful programmer.

Understand how the language works

Programmers cannot write good code unless they understand what they are typing. At the most basic level, this means they need to understand the rules of