Skip to content

Instantly share code, notes, and snippets.

View Fullstop000's full-sized avatar
🎯
Focusing

Fullstop000 Fullstop000

🎯
Focusing
  • Hangzhou Zhejiang
View GitHub Profile
public String triangleGenerator(int num, char letter ){
if(num%2==0){
num++
}
// int num = 21; // input num (assume odd)
// char letter = 'A'; // input char
int rows = (num+1)/2; // the amount of rows
String result = "";
int rowIdx = 1; // assume the idx of first row is 1
@Fullstop000
Fullstop000 / client.js
Last active September 30, 2017 06:50
Websocket client & server
const url = 'ws://localhost:1234'
let ws = new WebSocket(url,'test_protocol')
ws.onopen = () => {
console.log('Client connection opened')
ws.send('Hello Websocket')
}
ws.onmessage = (event) => {
console.log('Received message : '+ event.data)
}
@Fullstop000
Fullstop000 / npmrc
Last active February 1, 2018 02:09
The npmrc file using npm taobao mirror
registry=https://registry.npm.taobao.org
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=http://cdn.npm.taobao.org/dist/phantomjs
electron_mirror=http://cdn.npm.taobao.org/dist/electron/
@Fullstop000
Fullstop000 / genesis_public_key
Last active February 22, 2018 04:47
genesis_public_key
04c0c0e476bd9f08980c6451372e78fa3accea476a6206b2219c3fe67fdf1bebdf0c7827f93e7f864f7ef778f83f053bb08c790977cc632cb81e987f6121cfe7a5
@Fullstop000
Fullstop000 / delay.js
Last active April 21, 2020 03:30
A synchonized delay js function
/**
* This delay function returns a Promise which will fullfill when the timer goes off
*/
export default function delay(fn, duration) {
return new Promise(resolve => setTimeout(() => { fn(); resolve()}), duration)
}
@Fullstop000
Fullstop000 / unix_permission.md
Last active April 23, 2018 06:08
What unix permission code means
+-----+---+--------------------------+
| rwx | 7 | Read, write and execute  |
| rw- | 6 | Read, write              |
| r-x | 5 | Read, and execute        |
| r-- | 4 | Read,                    |
| -wx | 3 | Write and execute        |
| -w- | 2 | Write                    |
| --x | 1 | Execute                  |
| --- | 0 | no permissions |
use mio::{Handler, EventLoop};
use std::{thread, time};
fn main() {
let mut event_loop = EventLoop::<MyHandler>::new().unwrap();
let sender = event_loop.channel();
let sender2 = sender.clone();
thread::spawn(move || {
loop {
thread::sleep(time::Duration::from_secs(1));
#[macro_export]
macro_rules! invarint {
($condition:expr, $($arg:tt)*) => {
if !$condition {
panic!($($arg)*);
}
};
}
@Fullstop000
Fullstop000 / dlist.rs
Created May 27, 2019 10:54
double-linked list using Rust
use std::cell::RefCell;
use std::rc::{Rc, Weak};
pub type NodePtr<T> = Rc<RefCell<Node<T>>>;
#[derive(Debug)]
pub struct Node<T> {
pub data: T,
pub prev: Option<Weak<RefCell<Node<T>>>>,
pub next: Option<Rc<RefCell<Node<T>>>>,
}
package common
import (
"fmt"
"reflect"
)
// `flatten` recursively retrieves every leaf node in a struct in depth-first fashion
// and aggregate the results into given string slice with format: "path.to.leaf = value"
// in the order of definition. Root name is ignored in the path. This helper function is