Skip to content

Instantly share code, notes, and snippets.

View dd1994's full-sized avatar
💭
I may be slow to respond.

JIANG Di dd1994

💭
I may be slow to respond.
View GitHub Profile
#include <stdio.h>
int main(void) {
int a = 0;
int b = 1;
printf("%d&%d=%d\n", a, b, a&b);
printf("%d&%d=%d\n", a, a, a&a);
printf("%d&%d=%d\n", b, b, b&b);
printf("%d|%d=%d\n", a, b, a|b);
@dd1994
dd1994 / getopt_long.c
Created October 11, 2015 12:21
a expamle of getopt_long
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
/* Flag set by ‘--verbose’. */
static int verbose_flag;
int main(int argc, const char *argv[]) {
int c;
@dd1994
dd1994 / getopt.c
Created October 2, 2015 06:31
Example of Getopt
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <ctype.h>
int main(int argc, const char *argv[]) {
bool aflag = false;
bool bflag = false;
@dd1994
dd1994 / word_count.rb
Created October 1, 2015 08:01
统计每个单词出现的次数
def word_count(str)
str_ary = str.split(" ")
str_hash = Hash.new(0)
str_ary.each do |s|
str_hash[s] += 1
end
return str_hash
end
@dd1994
dd1994 / restart.sh
Created September 30, 2015 13:43
auto restart when app crash
(while true; do
ss-qt5
done) &
@dd1994
dd1994 / pass.js
Created September 29, 2015 06:23
pass by value or pass by reference?
'use strict'
let func = (a, b, c) => {
a = "a-new-value"
b = b + "+ b-new-value"
c[0] = "c-new-value1"
}
let a = "a-old-value"
let b = "b-old-value"
#include <stdio.h>
int main(void) {
int a[3] = {1, 2, 3};
for (size_t i = 0; i < 3; i++) {
printf("%d\n", i[a]);
}
return 0;
}
@dd1994
dd1994 / active-record-migration-expert.md
Last active September 1, 2015 01:50 — forked from pyk/active-record-migration-expert.md
become active record migration expert (Rails 4.0.2)

become active record migration expert (Rails 4.0.2)

workflow:

create model

$ rails g model NameOfModel
    invoke  active_record
    create    db/migrate/YYYYMMDDHHMMSS_create_name_of_models.rb
/**
*
*    ┏┓   ┏┓
*   ┏┛┻━━━┛┻┓
*   ┃       ┃
*   ┃   ━   ┃
*   ┃ ┳┛ ┗┳ ┃
*   ┃       ┃
*   ┃   ┻   ┃
*   ┃       ┃

这几年,我只是一心想要前进,想要碰触那些无法触及的东西。 却不知道那具体指什么,也不清楚那可以说是威胁的想法从何而来。 只是不断的前进着,等我回过神来,日渐疲惫的心,是如此痛苦。 然后某一天清晨,我发觉自己从前那么认真诚恳的感情,已经消失得无影无踪,才了解到自己已经到了极限时,我辞职了。


我清楚的知道,我们无法保证将来能在一起,横亘在我们面前的是那沉重的人生和漫长的时间,让人望而却步。