Skip to content

Instantly share code, notes, and snippets.

View zhang-zedong's full-sized avatar
🏠
Working from home

Zedong Zhang zhang-zedong

🏠
Working from home
View GitHub Profile
@zhang-zedong
zhang-zedong / test
Created November 5, 2016 07:25
Hello, gist!
puts "Hello, gist!"
@zhang-zedong
zhang-zedong / order.rb
Last active April 23, 2017 15:22
order.rb
class Order < ApplicationRecord
belongs_to :user
has_many :order_items
def pay!
self.update_columns(is_paid: true)
end
include AASM
aasm do
state :order_placed, :initial => true
#include <stdio.h>
int main(int argc, const char * argv[]) {
int i = 0;
int j = 0;
while (j != 100) {
i = (i+1)%13;
j++;
if (j % 4==0) {
printf("%d ", i);
@zhang-zedong
zhang-zedong / list-huangchao.c
Created April 26, 2017 12:47
13个节点的循环链表按照mod4的方法输出
//
// main.c
// work-demo
//
// Created by 黄超 on 2017/4/26.
// Copyright © 2017年 黄超. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
@zhang-zedong
zhang-zedong / RAILS_CHEATSHEET.md
Created November 15, 2017 05:27 — forked from mdang/RAILS_CHEATSHEET.md
Ruby on Rails Cheatsheet

Ruby on Rails Cheatsheet

Architecture

Create a new application

Install the Rails gem if you haven't done so before

@zhang-zedong
zhang-zedong / FOR_Print.c
Created December 11, 2017 12:46
打印几个字符矩阵
#include<stdio.h>
void main(){
int i,j,n;
for(n=0;n<6;n++){
for(i=n,j=0;j<9;i++,j++){
printf("%c",'A'+i);
if(i==8){
i=-1;
}
}
@zhang-zedong
zhang-zedong / .bash_profile
Created April 1, 2018 13:33
my bash_profile
# Add `~/bin` to the `$PATH`
export PATH="$HOME/bin:$PATH";
# Load the shell dotfiles, and then some:
# * ~/.path can be used to extend `$PATH`.
# * ~/.extra can be used for other settings you don’t want to commit.
for file in ~/.{path,bash_prompt,exports,aliases,functions,extra}; do
[ -r "$file" ] && [ -f "$file" ] && source "$file";
done;
unset file;
@zhang-zedong
zhang-zedong / post-install.sh
Created August 9, 2019 16:38
安装三个容器的脚本
#!/usr/bin/env bash
# aws s3 cp --acl public-read post-install.sh s3://zedong-hpc-bucket/post-install.sh
# This script runs as root.
# Disable Intel Hyper-Threading Technology at runtime
for cpunum in $(cat /sys/devices/system/cpu/cpu*/topology/thread_siblings_list | cut -s -d, -f2- | tr ',' '\n' | sort -un)
do
echo 0 > /sys/devices/system/cpu/cpu$cpunum/online
done
@zhang-zedong
zhang-zedong / check_equaltree.py
Last active May 25, 2021 04:15
check if a tree can divid into 3 equal subtree, just alowing cut at root .
# check if a tree can divid into 3 equal subtree, just alowing cut at root .
class Node:
def __init__(self, val=None) -> None:
self.val = val
self.children = []
def generate_tree(inputs):
dic = {}
dic[1] = Node(1)
for pair in inputs:
# check if a tree can divid into 3 equal subtree, just alowing cut at root .
class Node:
def __init__(self, val=None) -> None:
self.val = val
self.children = []
def generate_tree(inputs):
dic = {}
dic[1] = Node(1)
for pair in inputs: