Skip to content

Instantly share code, notes, and snippets.

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

kenwoodjw

💭
I may be slow to respond.
View GitHub Profile
@kenwoodjw
kenwoodjw / client.py
Created April 15, 2017 07:26 — forked from dongweiming/client.py
知乎API爬虫
# coding=utf-8
import os
import json
import time
import requests
from requests.auth import AuthBase
from settings import LOGIN_URL, CAPTCHA_URL
from config import (
API_VERSION, APP_VERSION, APP_BUILD, UUID, UA, APP_ZA, CLIENT_ID,
@kenwoodjw
kenwoodjw / excel2mysql.py
Created January 19, 2018 06:42 — forked from anubhavsinha/excel2mysql.py
simple excel to mysql in python
# following Python packages needs to be installed
# xlrd, xlsxrd, unidecode, MySQLdb
import xlrd
import xlsxrd
import MySQLdb as mdb
import re
import unidecode
@kenwoodjw
kenwoodjw / latency.txt
Created April 11, 2018 11:41 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
#!/usr/bin/env bash
# #
# # Install main dependencies on CentOS:
# # Python 3.4.5, CMake 3.10.0, OpenCV 3.3.1
# # Author Andrii Lundiak (landike@gmail.com)
# #
# https://github.com/ageitgey/face_recognition/issues/191
# https://github.com/opencv/opencv/issues/8471
@kenwoodjw
kenwoodjw / asyncio-producer-consumer-task_done.py
Created May 30, 2018 06:05 — forked from tomschr/asyncio-producer-consumer-task_done.py
Producer/Consumer pattern for asyncio (Python >=3.4)
# Original source from http://asyncio.readthedocs.io/en/latest/producer_consumer.html
# Rewritten for Python >=3.4
import asyncio
import random
@asyncio.coroutine
def produce(queue, n):
for x in range(n):
Command to run:
ssh -L 2222:localhost:8501 user@remoteserver.com
where 2222 is the local port mapping it can be any number above 1000
where localhost must be set to localhost and refers to your current connection
where 8501 is the port you will be opening up on the remote machine
where user@remoteserver.com is the first hop in your quest for internal access
@kenwoodjw
kenwoodjw / parse_dotenv.bash
Created November 16, 2018 06:44 — forked from judy2k/parse_dotenv.bash
Parse a .env (dotenv) file directly using BASH
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
@kenwoodjw
kenwoodjw / jinja_variables_types.yml
Created June 22, 2020 03:18 — forked from spiette/jinja_variables_types.yml
Test the variables types in jinja2 templates, used here with ansible
---
- hosts: all
gather_facts: no
vars:
string: "string"
list:
- item1
- item2
dict:
key1: value1
@kenwoodjw
kenwoodjw / parse_json_post.go
Created October 12, 2021 10:08 — forked from andreagrandi/parse_json_post.go
Parse a JSON http POST in GoLang
package main
import (
"encoding/json"
"fmt"
"net/http"
)
type test_struct struct {
Test string
[root@ip-11-0-0-239 centos]# firewall-cmd --zone=trusted --add-source=94.204.104.194/32
success
[root@ip-11-0-0-239 centos]# firewall-cmd --zone=trusted --add-source=94.206.104.194/32
success
[root@ip-11-0-0-239 centos]# firewall-cmd --zone=trusted
success
[root@ip-11-0-0-239 centos]# firewall-cmd --list-sources
You're performing an operation over default zone ('public'),
but your connections/interfaces are in zone 'trusted' (see --get-active-zones)
You most likely need to use --zone=trusted option.