Skip to content

Instantly share code, notes, and snippets.

View azhai's full-sized avatar
🪁
Focusing

azhai

🪁
Focusing
View GitHub Profile
@webwurst
webwurst / pyside_webkit_javascript.py
Created March 26, 2012 08:01
PySide/WebKit/Javascript
import sys
from PySide.QtCore import QObject, Slot
from PySide.QtGui import QApplication
from PySide.QtWebKit import QWebView
html = """
<html>
<body>
<h1>Hello!</h1><br>
anonymous
anonymous / synack.c
Created July 4, 2013 11:18
/*
** Copyright 2000
** by
** The Board of Trustees of the
** Leland Stanford Junior University.
** All rights reserved.
**
**
** Disclaimer Notice
**
@azhai
azhai / py_stat.py
Created November 20, 2013 13:06
python stat
# -*- coding: utf-8 -*-
import sys
import os, os.path
os.chdir(os.path.dirname(os.path.realpath(__file__))
if sys.getdefaultencoding() != 'utf-8':
reload(sys)
sys.setdefaultencoding('utf-8')
from datetime import datetime
@mineta
mineta / marinamele_sieve_atkin.py
Last active September 9, 2023 12:54
Python code. Sieve of Atkin algorithm to find prime numbers
import math
def atkin(nmax):
"""
Returns a list of prime numbers below the number "nmax"
"""
is_prime = dict([(i, False) for i in range(5, nmax+1)])
for x in range(1, int(math.sqrt(nmax))+1):
for y in range(1, int(math.sqrt(nmax))+1):
n = 4*x**2 + y**2
if (n <= nmax) and ((n % 12 == 1) or (n % 12 == 5)):
@denji
denji / http-benchmark.md
Last active July 14, 2024 06:25
HTTP(S) Benchmark Tools / Toolkit for testing/debugging HTTP(S) and restAPI (RESTful)
@danharper
danharper / gulpfile.js
Last active April 11, 2024 08:31
New ES6 project with Babel, Browserify & Gulp
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var babel = require('babelify');
function compile(watch) {
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel));
@saelo
saelo / decorator.go
Created March 8, 2015 19:45
Decorators in Go
package main
import (
"fmt"
"reflect"
)
func Decorate(impl interface{}) interface{} {
fn := reflect.ValueOf(impl)
@magnetikonline
magnetikonline / README.md
Last active November 25, 2023 13:59
Nginx & PHP-FPM systemd services.

Nginx & PHP-FPM systemd services

A basic set of systemd units for starting Nginx and PHP-FPM daemons on system startup.

  • Ensures Nginx web server has started before the PHP-FPM process.
  • Nginx pid file placed at /run/nginx.pid.
  • PHP-FPM pid file placed at /run/php7/php-fpm.pid, PHP7 PHP-FPM config at /etc/php7.
  • Based on usage with Ubuntu 16.04LTS / 18.04LTS.

Unit files are placed in /etc/systemd/system and enabled with:

@zupzup
zupzup / main.go
Created March 20, 2017 10:03
Go TCP Proxy / Port Forwarding Example (https://zupzup.org/go-port-forwarding/)
package main
import (
"flag"
"fmt"
"io"
"log"
"net"
"os"
"os/signal"
<?php
$uploadUrl = 'http://test.com/upload.php';
// 转发从其它客户端上传的文件,name="file"
upload_file($uploadUrl, realpath($_FILES['file']['tmp_name']), $_FILES['file']['type'], $_FILES['file']['name']);
/**
* curl上传文件
*/
function upload_file($url, $path, $type, $filename){