Skip to content

Instantly share code, notes, and snippets.

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

Yuan Fu casouri

💭
I may be slow to respond.
View GitHub Profile
@casouri
casouri / National Geographic Picture-Of-The-Day Wallpaper Script
Last active February 22, 2021 13:16 — forked from JoshSchreuder/National Geographic Picture-Of-The-Day Wallpaper Script
A BASH script to download National Geographic's picture of the day (http://photography.nationalgeographic.com/photography/photo-of-the-day) saving and setting as wallpaper automatically.
#!/bin/bash
# Copyright (c) 2011 Josh Schreuder
# http://www.postteenageliving.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@casouri
casouri / budget-process
Created September 30, 2017 21:13
create csv budget file from a list of records
# -*- coding: utf-8 -*-
'''
copy data into datain file under root folder
every record are separate by newling
first line is title
a csv file will be ceated
'''
import re
from csv import DictWriter
@casouri
casouri / rain-warning.py
Created October 10, 2017 22:42
rain-warning
#! /Users/yuan/p/morning/env/bin/python3
from twilio.rest import Client
from pyowm import OWM
import requests
import json
accountSID = 'AC4101e654b8cb7e5f9a22a4676ad65bf8'
authToken = '5ac4db2c7bd0a020cff1cf92d28af926'
destinationNumbers = ['+12675910741']
@casouri
casouri / ssl-demo.md
Last active December 31, 2017 22:35
how to add ssl security to a personal server
@casouri
casouri / connect-to-psu-wireless
Last active November 20, 2017 19:37
connect to psu wireless # linux # wpa_supplicant example #raspberry pi
# After several days experiment, I finally connected my RPi to psu wireless.
# Hope this helps anyone with the same issue
# Note: to convert the downloaded .der certidifate to .pem format,
# use `openssl x509 -inform der -in certificatename.der -out certificatename.pem` as provided at https://search.thawte.com/support/ssl-digital-certificates/index?page=content&actp=CROSSLINK&id=SO26449
network={
ssid="psu"
key_mgmt=WPA-EAP
eap=TTLS
@casouri
casouri / libpcp.rb
Created December 23, 2017 03:01
homebrew libpcp formula
# Documentation: https://docs.brew.sh/Formula-Cookbook.html
# http://www.rubydoc.info/github/Homebrew/brew/master/Formula
class Libpcp < Formula
desc "PCP client library"
homepage "https://github.com/libpcp/pcp"
url "https://github.com/libpcp/pcp/archive/master.zip"
version "0.0.1"
sha256 "5057f6cdc596c49f06d6f77ada82429452b0294d03f53ab32e8d3e3fbf201b37"
@casouri
casouri / git.org
Last active January 1, 2018 05:27
git tutorial - pulling everything together

Git tutorial - pulling everything together

So you have know something about git: you have create a repository on GitHub, cloned it to your computer, coded a bit and committed commits. Maybe even you have tried to create a new branch and merged it back. Everything looks so nice, until you dug a litter deeper. Where do you push to and pull from? What is fork? What about “pull request”? What is it’s relationship to pull? what is all this mess?

@casouri
casouri / upnp.c
Created January 5, 2018 20:19
simple libminiupnpc port mapping usage
#include <stdio.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <ifaddrs.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/upnpcommands.h>
@casouri
casouri / change-macro-convention.el
Last active February 3, 2018 15:54
change exclamation marks in macro definition to something else, because "!" makes me uncomfortable when I read them a lot in code.
(defun change-macro-in-buffer (str)
"change-macro-in-buffer(STR)
Change all defmacro's name that follows macro! convention to macro(STR) convention.
For example, macro! to macro|.
In a word, change all the \"!\"s in macro name to STRs.
Because exclamation marks makes my uncomfortable and I can."
(while (re-search-forward "defmacro.+?!" nil t)
(replace-match (replace-regexp-in-string "!" str (match-string 0)))))
@casouri
casouri / init.lua
Created April 7, 2018 02:18
sequential key bindings in hammerspoon
-- key to break out of every layer and back to normal
escapeKey = {keyNone, 'escape'}
-- max length of helper measured in character
recursiveBindHelperMaxLineLengthInChar = 80
-- format of helper, the helper is just a hs.alert
recursiveBindHelperFormat = {atScreenEdge=2,
strokeColor={ white = 0, alpha = 2 },
textFont='SF Mono'}