Skip to content

Instantly share code, notes, and snippets.

@congpeijun
congpeijun / dc1.json
Created September 29, 2019 04:13 — forked from FlashSoft/dc1.json
斐讯DC1(node-red flow)
[
{
"id": "966d4a60.9dcaa8",
"type": "tcp in",
"z": "f5965567.2c44c8",
"name": "",
"server": "server",
"host": "",
"port": "8000",
"datamode": "stream",
@congpeijun
congpeijun / mongodb-facet-combine.js
Created July 24, 2018 08:50 — forked from cthurston/mongodb-facet-combine.js
MongoDb combine $facet results into a single result set.
db.getCollection('list').aggregate([
{
$facet: {
"events":[{
$match: {
'type': 'Event'
}
}],
"tasks": [{
$match: {
@congpeijun
congpeijun / convert.php
Last active November 6, 2019 07:17
convert typecho to hexo
<?php
$db = new SQLite3('typecho.db');
$result = $db->query("SELECT a.cid, a.title, a.slug, a.text, a.created, a.status,
CASE c.type
WHEN 'tag' THEN group_concat(c.name)
END tags,
CASE c.type
WHEN 'category' THEN group_concat(c.name)
@congpeijun
congpeijun / pi_qemu.sh
Created February 1, 2017 12:30 — forked from JasonGhent/pi_qemu.sh
OSX raspberry pi emulation via QEMU. v2 attempt @ https://gist.github.com/JasonGhent/922f38f57c8cb77b10f3
# pulled from http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/
# expanded via http://superuser.com/questions/690060/how-to-enable-network-with-a-raspberry-pi-emulated-on-qemu
# tested with 2015-02-16-raspbian-wheezy.zip on OSX Mavericks
# OSX terminal
brew install qemu
# kernel-qemu is a linux kernel compiled with ARM1176 support.
# learn more here: http://xecdesign.com/compiling-a-kernel/
curl -OL http://xecdesign.com/downloads/linux-qemu/kernel-qemu
curl -o raspbian_latest.zip -L http://downloads.raspberrypi.org/raspbian_latest
@congpeijun
congpeijun / ddns.sh
Created July 29, 2016 13:49 — forked from TommyLau/ddns.sh
Tommy DnsPod DDNS Client
#!/bin/sh
########################################
#
# Tommy DnsPod DDNS Client v0.2.0
#
# Author: Tommy Lau <tommy@gen-new.com>
#
# Created: 2015-02-23 08:52:00 UTC
# Updated: 2016-07-15 15:48:00 UTC
@congpeijun
congpeijun / 0_reuse_code.js
Created March 26, 2014 02:18
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
@congpeijun
congpeijun / gist:5471986
Created April 27, 2013 05:23
postfix maildir
maildirmake /etc/skel/Maildir
maildirmake /etc/skel/Maildir/.Drafts
maildirmake /etc/skel/Maildir/.Sent
maildirmake /etc/skel/Maildir/.Trash
maildirmake /etc/skel/Maildir/.Templates
Then, for an existing user:
cp -r /etc/skel/Maildir /home/myuser/
chown -R myuser:usergroup /home/myuser/Maildir
chmod -R 700 /home/myuser/Maildir
@congpeijun
congpeijun / gist:5316036
Created April 5, 2013 02:01
fcitx-sogoupinyin
sudo add-apt-repository ppa:fcitx-team/nightly
@congpeijun
congpeijun / gist:5114193
Created March 8, 2013 04:20
Delete unuse kenal for ubuntu.
sudo aptitude purge ~ilinux-image-.*\(\!`uname -r`\)
@congpeijun
congpeijun / ical-RFC-2445-4.1.php
Created December 6, 2012 05:52 — forked from hugowetterberg/ical-RFC-2445-4.1.php
A useful function for splitting ical content into 75-octet lines, taking multibyte characters into account. See: http://www.ietf.org/rfc/rfc2445.txt, section 4.1
<?php
mb_internal_encoding("UTF-8");
$desc = <<<TEXT
<p>Lines of text SHOULD NOT be longer than 75 octets, (och hör på den) excluding the line break. Long content lines SHOULD be split into a multiple line representations using a line "folding" technique.</p>
That is, a long line can be split between any two characters by inserting a CRLF
immediately followed by a single linear white space character (i.e.,
SPACE, <b>US-ASCII</b> decimal 32 or HTAB, US-ASCII decimal 9). Any sequence
of CRLF followed immediately by a single linear white space character
is ignored (i.e., removed) when processing the content type.