Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View daqing's full-sized avatar

David Zhang daqing

View GitHub Profile
@daqing
daqing / main.go
Created March 26, 2024 04:20
Go SQLite demo
package main
import (
"database/sql"
"fmt"
"time"
_ "modernc.org/sqlite"
)
@daqing
daqing / ContentView.swift
Created March 25, 2024 12:20
iOS Weather App (demo)
//
// ContentView.swift
// SwiftUI-Weather
//
// Created by David Zhang on 2023/11/23.
//
import SwiftUI
struct ContentView: View {
@daqing
daqing / hello-world-socket.c
Created September 18, 2011 03:50
my first 'hello world' example for socket programming
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include <errno.h>
#include <sys/wait.h>
@daqing
daqing / .vimrc
Last active February 7, 2023 09:01
My Latest vim config
" General
set shell=/bin/zsh
set nocompatible " Disable vi compatibility
set history=256 " Number of things to remember
set autowrite " Writes on make/shell commands
set autoread
"set timeoutlen=250 " Time to wait after ESC (default causes an annoying delay)
set clipboard+=unnamed " Yanks go on clipboard instead
set tags=./tags;$HOME " Walk directory tree up to $HOME looking for tags
noremap <S-t> :! ctags -R --languages=Ruby --exclude=.git --exclude=log --exclude=node_modules -f tags<CR>
@daqing
daqing / .vimrc
Created February 26, 2009 08:01
my vim configuration file
set t_Co=256
set nocompatible
set mouse=a
syntax on
filetype on
filetype plugin on
set autowrite
set autoread
set number
@daqing
daqing / MetaTest.rb
Created April 22, 2011 06:04
understanding-class_eval-instance_eval-and-define_method
class Test
class_eval <<-END
def self.a
puts "a"
end
END
instance_eval <<-END
def b
puts "b"
@daqing
daqing / how-to-do-unit-test.md
Created June 27, 2019 03:10
How to test methods that call other methods

对于如何测试下面的方法,我现在的思考是:

def do_something
  do_action_one
  do_action_two(10)
  another.do_abc
  
  if ok?
 do_action_z
@daqing
daqing / Gemfile
Created March 22, 2015 20:01 — forked from ahaedike/Gemfile
source "https://rubygems.org"
gem 'eventmachine'
#gem 'rubysl-stringio'
gem 'sinatra'
gem 'yajl-ruby', require: 'yajl'
gem 'thin'
gem 'em-websocket', :git=>'https://github.com/igrigorik/em-websocket.git'
@daqing
daqing / install-docker.bash
Created May 18, 2018 06:17
install docker on ubuntu 16.04
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
@daqing
daqing / docker-ce-ubuntu-install.sh
Created March 23, 2017 08:43
Install Docker-CE on ubuntu
sudo apt update
sudo apt-get -y install \
apt-transport-https \
ca-certificates \
curl
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"