Skip to content

Instantly share code, notes, and snippets.

View qsun's full-sized avatar
🎯
Focusing

Quan qsun

🎯
Focusing
  • open
  • Sydney NSW Australia
View GitHub Profile
# Trying to make an appointment with someone as soon as possible.
import os
from datetime import datetime
from http.cookiejar import CookieJar
import requests
from bs4 import BeautifulSoup
notification_url = os.environ['IFTTT_WEBHOOK']
import serial
import aqi
def read_frame(ser):
bs = ser.read(2)
# print(['0x{:02x}'.format(x) for x in bs])
length = bs[0]*256+bs[1]
frame = ser.read(length)
pm1_0 = frame[0]*256+frame[1]
@qsun
qsun / use.c
Created January 11, 2019 14:12
mimic poll with IRQ (using C macro)
IT_WRAP(uart6_dma_in_progress, HAL_UART_Transmit_IT(&CLI_UART, (uint8_t *)(debug_log_str + debug_log_tail), len));
@qsun
qsun / kicad-jlc-smt-convert.py
Created August 26, 2018 10:51
convert kicad .pos SMT file into the one JLC uses.
import sys
import csv
import re
for filename in sys.argv[1:]:
print("Processing %s" % (filename,))
o_filename = filename + '-jlc.csv'
with open(filename, 'r') as i:
@qsun
qsun / deploy.sh
Created January 18, 2016 19:54
Deploy script for laravel
#!/bin/bash
set -e
set -x
/sbin/start-stop-daemon --stop --oknodo --pidfile /home/httpsreminder/queue.pid --retry=TERM/30/KILL/5
if [ -d httpsreminder.com ]; then
pushd httpsreminder.com
@qsun
qsun / index.go
Created July 27, 2015 07:16
Control max open dirs in Golang
// src/golang.org/x/tools/godoc/index.go, L993
// NewIndex creates a new index for the .go files provided by the corpus.
func (c *Corpus) NewIndex() *Index {
// initialize Indexer
// (use some reasonably sized maps to start)
x := &Indexer{
c: c,
fset: token.NewFileSet(),
fsOpenGate: make(chan bool, maxOpenFiles),
@qsun
qsun / flow.json
Last active August 29, 2015 14:14
flow
{
"days":[
{
"dateHuman":"Today",
"dateExact":"5 Feb 2015",
"stories":[
{
"title":"Sydney property prices climb even higher despite drop in activity over the summer holiday period",
"summary": "The combined value of houses and units increased 1.4 per cent over the month, growing just as values fell 1.2 per cent in Adelaide, 1.3 per cent in Darwin and 0.6 per cent in Perth.",
"url":"http://www.dailytelegraph.com.au/realestate/news/sydney-property-prices-climb-even-higher-despite-drop-in-activity-over-the-summer-holiday-period/story-fni0cly6-1227204906005",
@qsun
qsun / generated.sample.html
Last active August 29, 2015 14:14
mimo integration
<div id="ozsharing-sidebar">
<div id="ozsharing-listings-container">
<h2>近期租房信息</h2>
<div class="refresh">换一换</div>
<div class="ozsharing-listings">
<div id="ozsharing-featured-properties">
<div class="ozsharing-featured-property-wrapper">
<div class="ozsharing-featured-property">
<a target="_blank" class="ozsharing-featured-property-link" href="http://ozsharing.com/r/-ultimo-480-per-week-studio-bao-jia-ju-bao-bills-532075.html">
<div class="ozsharing-featured-property-title-wrapper"><span class="ozsharing-featured-property-title"> Ultimo $480 per/week studio包家具包bills</span></div>

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

#!/usr/bin/env bash
set +x
set +e
go build -ldflags "-X main.version $(git rev-parse HEAD)"