Skip to content

Instantly share code, notes, and snippets.

View legnaleurc's full-sized avatar

Wei-Cheng Pan legnaleurc

View GitHub Profile
@legnaleurc
legnaleurc / wv.py
Created December 27, 2014 03:26
webview example
#! /usr/bin/env python3
import sys
from PySide import QtGui, QtWebKit
app = QtGui.QApplication(sys.argv)
@legnaleurc
legnaleurc / arg.py
Created September 22, 2014 16:16
argparse bug
from __future__ import unicode_literals
from __future__ import print_function
import argparse
a = argparse.ArgumentParser()
b = a.add_subparsers(dest='command')
b.add_parser('test')
c = a.parse_args([])
print(c.command is None)
@legnaleurc
legnaleurc / etc_hosts
Last active January 26, 2022 12:54
Fix pod files for OpenSSL 1.0.1g
#192.168.1.100 ddld.loc.al
#127.0.0.1 ddld.loc.al
#127.0.0.1 www.gstatic.com
127.0.0.1 www.google-analytics.com
127.0.0.1 www.googletagmanager.com
#127.0.0.1 www.googleadservices.com
#127.0.0.1 ade.googlesyndication.com
#127.0.0.1 tpc.googlesyndication.com
#127.0.0.1 pagead2.googlesyndication.com
#127.0.0.1 securepubads.g.doubleclick.net
@legnaleurc
legnaleurc / telnet_client.c
Last active April 17, 2023 06:21
Simple Telnet Client
/* http://l3net.wordpress.com/2012/12/09/a-simple-telnet-client/ */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <arpa/inet.h>
#include <termios.h>
#include <fcntl.h>
std::vector<std::string> findSubstrings(std::vector<std::string> words, std::vector<std::string> parts) {
sort(begin(parts), end(parts), [](const std::string & a, const std::string & b) -> bool {
return a.size() > b.size();
});
for (int i = 0; i < words.size(); ++i) {
words[i] = highlight(words[i], parts);
}
return words;
}
@legnaleurc
legnaleurc / ncu_sign.py
Last active February 5, 2020 01:39 — forked from eternnoir/gist:5797146
NCU sign in/out
#! /usr/bin/env python
import cookielib
import sys
import urllib
from BeautifulSoup import BeautifulSoup
import mechanize
@legnaleurc
legnaleurc / h264.c
Last active December 17, 2015 05:09
h.264
#define _BSD_SOURCE
#include <endian.h>
// #include "bs.h"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
@legnaleurc
legnaleurc / json.cpp
Created July 2, 2012 04:24
JSON parser with Boost Spirit
#include <boost/any.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/fusion/include/std_pair.hpp>
#include <vector>
#include <map>
#include <iostream>
namespace json {
#include <iostream>
#include <chrono>
#include <queue>
#include <boost/asio/io_service.hpp>
#include <boost/asio/steady_timer.hpp>
#include <boost/asio/strand.hpp>
class Runner {
@legnaleurc
legnaleurc / kdesrc-curses.rst
Created November 8, 2011 16:54
kdesrc-curses

kdesrc-curses

Idea for homebrew-like kdesrc-build, I'll call it kdesrc-curses

Concepts

  • Scriptable: new program or module should be easily add. Simply add a new file and inherit some classes.