Skip to content

Instantly share code, notes, and snippets.

@steelywing
steelywing / linux.md
Last active October 22, 2017 08:03
linux

Network

Obsolete command

  • ifconfig => ip addr and ip link
  • netstat => ss, ip route

Set interface up on boot

/etc/sysconfig/network

NETWORKING=yes
@steelywing
steelywing / service.py
Created August 6, 2014 01:40
python windows service
import win32serviceutil
import win32service
import win32event
import servicemanager
# import signal
# import os
from multiprocessing import Process
from main import app
import re
import csv
import sys
import requests
from requests.exceptions import RequestException
import threading
from subprocess import call
from bs4 import BeautifulSoup
from html.parser import HTMLParseError
from urllib.parse import urljoin
@steelywing
steelywing / WinImage-KeyGen.html
Last active March 10, 2024 12:14
winimage 9.0 keygen
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>WinImage 9.0 KeyGen</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body style="text-align: center;">
<h1>WinImage 9.0 KeyGen</h1>
@steelywing
steelywing / JavaScript Class.md
Last active August 29, 2015 14:01
javascript class explain
function Class() {}

actually

Class.prototype = new Object();
Class.prototype.constructor = Class;
@steelywing
steelywing / format_number.js
Last active October 28, 2020 04:50
JavaScript format number
/**
* Format number
*
* (1234567.8).format(2)
* => "1,234,567.80"
*
* precision: decimal precision
*/
// Method 0 (http://stackoverflow.com/a/14428340/1877620)
-- This will replace the other fields to default value
INSERT OR REPLACE INTO book(id, name) VALUES(1001, 'Programming');
-- INSERT OR UPDATE (Method 1)
INSERT OR IGNORE INTO book(id) VALUES(1001);
UPDATE book SET name = 'Programming';
-- INSERT OR UPDATE (Method 2)
INSERT OR REPLACE INTO book (id, name)
VALUES (1001, 'Programming',
from flask import Flask
from werkzeug.routing import BaseConverter
app = Flask(__name__)
class RegExConverter(BaseConverter):
def __init__(self, map, regex='[^/]+'):
super().__init__(map)
self.regex = regex
@steelywing
steelywing / mro.py
Created March 19, 2014 07:18
python multiple inheritance
class Base(object):
def __init__(self, c):
print('Base called by {0}'.format(c))
super().__init__()
class ParentA(Base):
def __init__(self, c):
print('ParentA called by {0}'.format(c))
#Base.__init__(self, 'ParentA')
super().__init__('ParentA')
@steelywing
steelywing / jquery.plugin.js
Last active March 11, 2020 19:57
jQuery plugin boilerplate
/*
* Project:
* Description:
* Author:
* License:
*/
// the semi-colon before function invocation is a safety net against concatenated
// scripts and/or other plugins which may not be closed properly.
;(function ($, window, document, undefined) {