Skip to content

Instantly share code, notes, and snippets.

@windows98SE
windows98SE / api.py.patch
Created May 23, 2015 15:18
[fix] LINE API function login ( api.py ) / new examples
@@ -55,7 +55,21 @@
After login, make `client` and `client_in` instance
to communicate with LINE server
"""
- raise Exception("Code is removed because of the request of LINE corporation")
+
+ self.transport = THttpClient.THttpClient(self.LINE_HTTP_URL)
+ self.transport_in = THttpClient.THttpClient(self.LINE_HTTP_IN_URL)
+
+ self.transport.setCustomHeaders(self._headers)
from itertools import product
from functools import reduce
class Number():
def __init__(self):
self.num = 0
def succ(self):
self.num += 1
return self
@MarkZhangTW
MarkZhangTW / curl.time.sh
Last active April 10, 2020 06:03
Curl format for displaying time infomation.
#!/usr/bin/env bash
# Reference: https://stackoverflow.com/questions/18215389/how-do-i-measure-request-and-response-times-at-once-using-curl
curl_format="\
%{time_namelookup}:\
%{time_connect}:%{time_appconnect}:\
%{time_pretransfer}:%{time_redirect}:\
%{time_starttransfer}:%{time_total}"
curl_result=$(echo "$curl_format" | curl -s -o /dev/null -w @- $@)
IFS=':' read -r -a array <<< "$curl_result"
@rozifus
rozifus / Python SimpleHTTPServer with SSL
Last active October 9, 2022 22:40
Python SimpleHTTPServer with SSL
# useful for running ssl server on localhost
# which in turn is useful for working with WebSocket Secure (wss)
# copied from http://www.piware.de/2011/01/creating-an-https-server-in-python/
@troynt
troynt / better_dvorak.ahk
Created October 8, 2009 15:17
Dvorak Autohotkey
; Use Scroll Lock to swap keyboard layouts
; and do not let Control, Alt, or Win modifiers act on Dvorak
Loop {
If GetKeyState("ScrollLock", "T")
and !GetKeyState("Control")
and !GetKeyState("Alt")
and !GetKeyState("LWin")
and !GetKeyState("RWin") {
Suspend, Off
} else {
@trendels
trendels / rsync_daemon_over_ssh.md
Last active November 13, 2023 03:26
Rsync daemon mode over ssh

rsync daemon mode over ssh

There are several common ways to do rsync backups of hosts over ssh:

  1. As a non-root user. Upsides: very secure. Downside: cannot back up sensitive files.
  2. As root, with a public key. Downsides: Whoever has the private key has full root access to the host being backed up.
  3. As root, with a public key and a "forced command". Upsides: Restricts access to the server. Downsides: Requires either careful matching of rsync options (which might change over time), or "validator" scripts. Neither idea sounds very appealing to me.
  4. Running rsync in daemon mode on the host being backed up. Upsides: Lots of useful options, like read-only mode, running as a different user if required, server-side excludes/includes, etc. Downsides: Opens up a TCP port that has full filesystem read access and is hard to secure (Ideally you could make the rsync daemon use a unix socket instead, that could be secured by filesystem permissions, but I haven't found a way to do that).

Here is another option t

@ericdouglas
ericdouglas / super-tip.txt
Last active February 25, 2024 10:09
Change 4 spaces to 2 spaces indentation and change tab to spaces - Vim tip
// 4 spaces to 2 spaces
%s;^\(\s\+\);\=repeat(' ', len(submatch(0))/2);g
// Tab to 2 spaces
:%s/\t/ /g
@w0rd-driven
w0rd-driven / passwords.txt
Created November 18, 2016 20:19
BFG Repo-Cleaner --replace-text example
PASSWORD1 # Replace literal string 'PASSWORD1' with '***REMOVED***' (default)
PASSWORD2==>examplePass # replace with 'examplePass' instead
PASSWORD3==> # replace with the empty string
regex:password=\w+==>password= # Replace, using a regex
regex:\r(\n)==>$1 # Replace Windows newlines with Unix newlines
@soheilhy
soheilhy / nginxproxy.md
Last active March 22, 2024 08:54
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@wmealing
wmealing / C-states.md
Last active March 29, 2024 22:51
What are CPU "C-states" and how to disable them if needed?

To limit a CPU to a certain C-state, you can pass the processor.max_cstate=X option in the kernel line of /boot/grub/grub.conf.

Here we limit the system to only C-State 1:

    kernel /vmlinuz-2.6.18-371.1.2.el5 ... processor.max_cstate=1

On some systems, the kernel can override the BIOS setting, and the parameter intel_idle.max_cstate=0 may be required to ensure sleep states are not entered: