Skip to content

Instantly share code, notes, and snippets.

View nix010's full-sized avatar

Nix nix010

  • Lisbon, Portugal or HCM, Vietnam
  • 10:07 (UTC)
View GitHub Profile
INSTALLED_APPS = [
'wpadmin',
'core.apps.CoreConfig',
'news.apps.NewsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
@nix010
nix010 / 0_reuse_code.js
Created September 5, 2017 09:56
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
class SupplierListView(TemplateView):
template_name = 'supplier/list.html'
def get(self, request, *args, **kwargs):
suppliers = Supplier.objects.all()
return self.render_to_response({
'suppliers':suppliers
})
@nix010
nix010 / install_cuda.sh
Last active November 24, 2017 04:04 — forked from trungkak/tf.sh
Tensorflow GPU installation on Ubuntu 16.04
# 1. Install CUDA
# Preparation
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install tmux build-essential gcc g++ make binutils
sudo apt-get install software-properties-common
# Download Cuda toolkit (Nvidia driver included)
cd ~/Downloads
# Download CUDA 8.0 from this https://developer.nvidia.com/cuda-80-ga2-download-archive, not 9.0
@nix010
nix010 / django_stuffs
Created January 19, 2018 15:06
snippets Django
$.ajaxSetup({
headers: { 'X-CSRFToken': "{{ csrf_token }}" }
});
@nix010
nix010 / base_crawler.py
Created January 26, 2018 19:11
crawl pictures from Pinterest by search a keyword
from bs4 import BeautifulSoup as BS
import requests
class BaseCrawler(object):
api_url = None
default_headers = {
'Accept-Language' :'en-US,en,q=0.9,vi;q=0.8',
@nix010
nix010 / base_crawler.py
Last active February 26, 2019 09:49
Crawl pictures from Pinterest by search a keyword | 26 Jan, 2018 (TESED )
from bs4 import BeautifulSoup as BS
import requests
class BaseCrawler(object):
api_url = None
default_headers = {
'Accept-Language' :'en-US,en,q=0.9,vi;q=0.8',
$.ajax({
method: "POST",
url: '{% url 'aj_location' %}',
dataType:'json',
data: {'data':this.dataset.gmap},
success: function(data){
if(data.is_saved){
alert('Added '+data.data.name);
}else{
# sudo add-apt-repository ppa:certbot/certbot && sudo apt-get update && sudo apt-get install -y python-certbot-nginx
# sudo certbot --nginx -d {domain}.com -d www.{domain}.com
# django app
# ...
# Check cronjobs
# cat /etc/cron.d/certbot
# Expires map cache
map $sent_http_content_type $expires {
default off;
// https://docs.google.com/presentation/d/1rrYLHVR3_Fc7mmvc8I8zGOhtoBDN02RjF_-aecimZdg/edit?usp=sharing
#include <NewPing.h>
#define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN 11 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 100 // Maximum distance we want to ping for (in centimeters). Maximum sensor
#define US_ROUNDTRIP_CM 58
void setup() {
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
pinMode(ECHO_PIN, OUTPUT);// Open serial monitor at 115200 baud to see ping results.