Skip to content

Instantly share code, notes, and snippets.

View ducva's full-sized avatar

Vu Anh Duc ducva

  • Resola.ai
  • Viet Nam
View GitHub Profile
@ducva
ducva / sample.py
Created May 27, 2020 15:26
how to apply decorator
@decorator
def func_name():
pass
@ducva
ducva / App.tsx
Created March 1, 2019 16:26
How to use useFormInput
function App() {
const birthday = useFormInput();
return (
<div className="App">
<Grid textAlign="center" style={{ height: '100%' }} verticalAlign="middle">
<Grid.Column style={{ maxWidth: 450 }}>
<Form size="large">
<Segment stacked={true}>
<Form.Input
fluid={true}
@ducva
ducva / useFormInput - use
Created March 1, 2019 16:17
how to use useFormInput
<Form.Input
fluid={true}
icon="calendar"
iconPosition="left"
placeholder="Your birthday"
type="date"
{...birthday}
/>
@ducva
ducva / useFormInput
Created March 1, 2019 16:12
simple useState
function useFormInput() {
const [value, setValue] = useState();
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setValue(e.target.value);
};
return {
value,
onChange: handleChange,
};
@ducva
ducva / cloudSettings
Created April 18, 2018 21:35
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-04-18T21:37:05.918Z","extensionVersion":"v2.9.0"}
@ducva
ducva / index.html
Last active May 16, 2017 22:31
sample
<html lang=”en”>
<head>
<link rel=”preload” href=”./vendor.js” as=”script”>
<link rel=”preload” href=”./app.js” as=”script”>
<body>
<main id=”root” style=”height: 100%”></main>
<script type=”text/javascript”>
scripts = [‘./vendor.js’,’./app.js’];
if (!(“fetch” in window && “Promise”)) {
scripts.unshift(‘./polyfills.js’);
@ducva
ducva / be_same_file_as.rb
Created January 24, 2017 07:04 — forked from mattwynne/be_same_file_as.rb
RSpec matcher to compare two file, using their MD5 hashes
RSpec::Matchers.define(:be_same_file_as) do |exected_file_path|
match do |actual_file_path|
md5_hash(actual_file_path).should == md5_hash(exected_file_path)
end
def md5_hash(file_path)
Digest::MD5.hexdigest(File.read(file_path))
end
end
@ducva
ducva / 0_reuse_code.js
Created December 21, 2016 19:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ducva
ducva / git.migrate
Created October 9, 2015 07:48 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.