Install the Rails gem if you haven't done so before
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // main.c | |
| // work-demo | |
| // | |
| // Created by 黄超 on 2017/4/26. | |
| // Copyright © 2017年 黄超. All rights reserved. | |
| // | |
| #include <stdio.h> | |
| #include <stdlib.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| puts "Hello, gist!" |
