Skip to content

Instantly share code, notes, and snippets.

View kholidfu's full-sized avatar
🏠
Working from home

Kholid Fuadi kholidfu

🏠
Working from home
View GitHub Profile
@kholidfu
kholidfu / bash-prompt-mac-2019.sh
Created March 7, 2019 01:46
Bash Prompt Mac 2019
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
@kholidfu
kholidfu / go_request_json_parse.go
Last active March 8, 2019 06:26
HTTP request to JSON and parse it
// @kholidfu - https://kholidfu.blogspot.com
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
@kholidfu
kholidfu / export_yt_channel_videos_to_csv.py
Created August 14, 2017 14:35
Export Youtube Channel Videos to CSV using Python3 + Youtube Api
import requests # or urllib
import csv
# get Youtube Data API Key
API_KEY = "" # insert your API key
# youtube channel ID
channel_id = "" # insert Youtube channel ID
page_token = ""
@kholidfu
kholidfu / django_get_random_model_id.py
Created May 21, 2017 17:47
get random id from django model
import random
from app.models import Collection
c = Collection.objects.filter(done=True).values('id')
rid = [i['id'] for i in c]
random.choice(rid)
class NumberOfImagesFilter(admin.SimpleListFilter):
"""Filter based on numbers of images.
== 7
> 6
< 7
"""
title = _('Number of Images')
parameter_name = 'imgcount'
def lookups(self, request, model_admin):
@kholidfu
kholidfu / django_reset.py
Created February 27, 2017 15:06
django reset all
import os
import glob
import subprocess
from sys import stdout, stdin, stderr
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
class Command(BaseCommand):
@kholidfu
kholidfu / .bash_prompt.sh
Last active November 18, 2016 10:51
custom bash_prompt, show virtualenv, git repo, yet simple!
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current git repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
location /images/ {
autoindex on;
alias /home/banteng/git/blooms/app/assets/;
}
# maka jika kita punya URL /images/11/03/blabla.jpg akan otomatis ter-map ke dir app/assets/11/03/blabla.jpg
# nice! tidak perlu ubah folder name!!!
reference: http://stackoverflow.com/questions/1474374/nginx-doesnt-serve-static
@kholidfu
kholidfu / Vagrantfile
Created May 23, 2016 14:38
vagrantfile_mac
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@kholidfu
kholidfu / install_grpcio.sh
Last active October 18, 2015 06:59
How to Install GRPCIO di Ubuntu 15.04 Vivid
# install grpcio
# =====
sudo apt-get install python-dev protobuf-compiler python-pip unzip dh-autoreconf
sudo pip install virtualenv
git clone https://github.com/grpc/grpc
cd grpc && git submodule update --init
# cd third_party/protobuf && ./autogen.sh
cd ~/grpc && make