Skip to content

Instantly share code, notes, and snippets.

View hesoyamcode's full-sized avatar
💭
I may be slow to respond.

fu hesoyamcode

💭
I may be slow to respond.
  • Singapore
View GitHub Profile
@hesoyamcode
hesoyamcode / Progressive Image React
Created July 23, 2018 07:14
Progressive Image with React
import React, { Component } from 'react';
import PropTypes from 'prop-types';
class ProgressiveImage extends Component {
static propTypes = {
preview: PropTypes.string,
image: PropTypes.string
};
state = {
@hesoyamcode
hesoyamcode / terminal
Created July 1, 2018 18:42
Remove .DS_Store
cd into directory you want to remove .DS_Store
then type
find . -name '.DS_Store' -type f -delete
@hesoyamcode
hesoyamcode / word2vec
Created June 27, 2018 20:39
Word2Vec
from gensim.models.word2vec import Word2Vec
from sklearn.manifold import TSNE
from sklearn.datasets import fetch_20newsgroups
import re
import matplotlib.pyplot as plt
# download example data ( may take a while)
train = fetch_20newsgroups()
def clean(text):
@hesoyamcode
hesoyamcode / command
Last active June 21, 2018 15:47
Docker ps -s
The "size" and "virtual size" describe the amount of disk space used by a container. Let me try and explain:
When starting a container, the image that the container is started from is mounted read-only. On top of that, a writable layer is mounted, in which any changes made to the container are written.
The read-only layers of an image can be shared between any container that is started from the same image, whereas the "writable" layer is unique per container (because: you don't want changes made in container "a" to appear in container "b" 😄)
Back to the docker ps -s output;
- The "size" information shows the amount of data (on disk) that is used for the writable layer of each container
- The "virtual size" is the amount of disk-space used for the read-only image data used by the container.
@hesoyamcode
hesoyamcode / command
Created June 21, 2018 15:46
Accessing Shell Node Docker
Node:latest
docker exec -it container_name /bin/bash
node:alpine
docker exec -it container_name /bin/sh
{
"presets": [
"env"
]
}
@hesoyamcode
hesoyamcode / git log graph
Created May 26, 2018 10:44
The --graph flag that will draw a text based graph of the commits on the left hand side of the commit messages. --decorate adds the names of branches or tags of the commits that are shown. --oneline shows the commit information on a single line making it easier to browse through commits at-a-glance.
git log --graph --decorate --oneline
@hesoyamcode
hesoyamcode / include Jquery to Console
Created May 23, 2018 10:47
Include JQuery into web console, just paste this script into your console
var script = document.createElement("script");
script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
@hesoyamcode
hesoyamcode / Git Log Pretty
Last active May 21, 2018 05:30
Git log pretty
git log --pretty=format:'%h : %s' --graph > log.log
cat log.log
@hesoyamcode
hesoyamcode / docker-remove-previous-image
Last active May 13, 2018 16:54
Docker remove previous image
Docker command to remove only dangling images
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)