Skip to content

Instantly share code, notes, and snippets.

View seanwu1105's full-sized avatar
💱
Write colorful texts on a dark screen for living.

Shuang Wu seanwu1105

💱
Write colorful texts on a dark screen for living.
View GitHub Profile
@seanwu1105
seanwu1105 / c_cpp_properties.json
Created February 10, 2018 16:56
The default c_cpp_properties.json for Visual Studio Code
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"defines": [],
@seanwu1105
seanwu1105 / SplitLineInVector.cpp
Created March 14, 2018 15:12
Split the string line by normal delimiters. Returns a vector containing all words in it.
std::vector<std::string> SplitLine(const std::string &line)
{
std::vector<std::string> tokens;
std::stringstream ss(line);
copy(std::istream_iterator<std::string>(ss),
std::istream_iterator<std::string>(),
back_inserter(tokens));
return tokens;
}
@seanwu1105
seanwu1105 / basic.qml
Created March 22, 2018 07:29
NO! It cannot be pyinstallered!
import QtQuick 2.0
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
ApplicationWindow {
visible: true
Material.theme: Material.Dark
Material.accent: Material.Purple
@seanwu1105
seanwu1105 / IPv4.l
Created March 22, 2018 10:50
The LEX to filter the IPv4 format.
%{
#include <iostream>
#include <string>
%}
integer_in_ipv4 0|1([0-9][0-9]?)?|2([5-9]|[0-4][0-9]?|5[0-5]?)?|[3-9][0-9]?
ipv4 {integer_in_ipv4}\.{integer_in_ipv4}\.{integer_in_ipv4}\.{integer_in_ipv4}
%%
@seanwu1105
seanwu1105 / compile_yacc.sh
Last active June 14, 2018 07:23
Bison and Flex Assignments - Matrix Dimension Checker
#!/bin/bash
if (("$#" < 2)) || (("$#" > 3)); then
echo "Illegal number of arguments"
exit 1
fi
bison -v -d -o "y.tab.c" $2
gcc -c -g -I.. "y.tab.c"
flex -o lex.yy.c $1
gcc -c -g -I.. lex.yy.c
if [ "$#" -eq 2 ]; then
@seanwu1105
seanwu1105 / compile_yacc.sh
Last active June 14, 2018 07:23
Bison and Flex Assignments - Equilibrium
#!/bin/bash
if (("$#" < 2)) || (("$#" > 3)); then
echo "Illegal number of arguments"
exit 1
fi
bison -v -d -o "y.tab.c" $2
gcc -c -g -I.. "y.tab.c"
flex -o lex.yy.c $1
gcc -c -g -I.. lex.yy.c
if [ "$#" -eq 2 ]; then
@seanwu1105
seanwu1105 / README.md
Created June 29, 2018 12:18
Using pyrcc5 to Help Pyinstaller Import External Sources Example

Using pyrcc5 to Help Pyinstaller Import External Sources Example

Dependencies

PyQt5

pip install PyQt5
@seanwu1105
seanwu1105 / flatten.py
Created July 14, 2018 02:26 — forked from ma-ric/flatten.py
Python; recursive flatten of nested iterables, with proper handling of string elements
#!/usr/bin/env python3
import collections
def flatten(t):
"""
Generator flattening the structure
>>> list(flatten([2, [2, "test", (4, 5, [7], [2, [6, 2, 6, [6], 4]], 6)]]))
[2, 2, "test", 4, 5, 7, 2, 6, 2, 6, 6, 4, 6]
"""
@seanwu1105
seanwu1105 / articles_list_spider.py
Last active July 21, 2018 11:52
Wikipedia zhTW Article Names Spider
import scrapy
class ArticlesListSpider(scrapy.Spider):
name = "articles_list"
page_counter = 0
def start_requests(self):
urls = [
r'https://zh.wikipedia.org/wiki/Special:%E6%89%80%E6%9C%89%E9%A1%B5%E9%9D%A2'
@seanwu1105
seanwu1105 / pyqt5.py
Created August 14, 2018 05:26
PySide2 QThread Issue
import sys
from PyQt5.QtCore import QThread
from PyQt5.QtWidgets import (QApplication, QMainWindow, QPushButton,
QComboBox, QWidget, QVBoxLayout)
class Task(QThread):
def run(self):
print('task started')