Skip to content

Instantly share code, notes, and snippets.

View msg7086's full-sized avatar

Xinyue Lu msg7086

  • Greater Portland, OR
  • 21:32 (UTC -07:00)
View GitHub Profile
@msg7086
msg7086 / v2ex-181180.php
Created April 3, 2015 09:22
v2ex-181180
<?php
$hash = [];
foreach($rows as &$row) {
$key = $row['period'] << 32 | $row['price'];
if (isset($hash[$key]))
$hash[$key]['num'] += $row['num'];
else {
unset($row['id']);
$hash[$key] = $row;
@msg7086
msg7086 / add-missing-param-sei.patch
Created March 26, 2015 22:44
This patch is put in the public domain.
# HG changeset patch
# Parent dc7a6c5fbda13173004e6193f185ea857d7a22c8
param: add missing parameters in sei
diff -r dc7a6c5fbda1 source/common/param.cpp
--- a/source/common/param.cpp Thu Mar 26 11:24:23 2015 -0500
+++ b/source/common/param.cpp Thu Mar 26 15:39:50 2015 -0700
@@ -1383,6 +1383,7 @@
s += sprintf(s, " crqpoffs=%d", p->crQpOffset);
s += sprintf(s, " rd=%d", p->rdLevel);
@msg7086
msg7086 / sum.cpp
Last active August 29, 2015 14:07
#include <stdio.h>
#include <sys/time.h>
long long sum[4] __attribute__((aligned(32))) = {1LL, 2LL, 3LL, 4LL};
long long four[4] __attribute__((aligned(32))) = {4LL, 4LL, 4LL, 4LL};
int main() {
struct timeval start, end;
gettimeofday(&start, NULL);
__asm__ (
void Recursive_Gaussian2D_Horizontal(double * output, const double * input, int width, int height, int stride, const double B, const double B1, const double B2, const double B3)
{
5BD13750 push ebp
5BD13751 mov ebp,esp
5BD13753 sub esp,0Ch
5BD13756 push ebx
5BD13757 mov eax,edx
5BD13759 mov ebx,ecx
int i, j, lower, upper;
double P0, P1, P2, P3;
#include <stdio.h>
#define bread(buffer) fread(&buffer, sizeof(buffer), 1, fp)
int to_i(unsigned char* data) {
return (data[3]<<0) | (data[2]<<8) | (data[1]<<16) | (data[0]<<24);
}
int main() {
char* source = "00012.clpi";
#include <stdio.h>
int main() {
int m, n;
scanf("%d%d", &m, &n);
int p[m], j = m - 1;
for(int i = 0; i < m - 1; i++) p[i] = i + 1;
p[m - 1] = 0;
while(p[j] != j) {
for(int i = 0; i < n - 1; i++) j = p[j];
Host Loss% Snt Last Avg Best Wrst StDev
4. ae-50-0-ar03.beaverton.or.bverton.comcast.net 0.0% 20 9.6 17.3 9.3 49.9 12.2
5. ae-1-0-ar03.troutdale.or.bverton.comcast.net 0.0% 20 13.6 20.4 9.8 69.8 17.0
ae-0-0-ar03.troutdale.or.bverton.comcast.net
6. he-3-6-0-0-11-cr01.dallas.tx.ibone.comcast.net 0.0% 20 16.2 18.7 15.7 22.6 1.7
he-2-2-0-0-11-cr01.seattle.wa.ibone.comcast.net
he-2-0-0-0-10-cr01.seattle.wa.ibone.comcast.net
pos-2-3-0-0-cr01.newyork.ny.ibone.comcast.net
he-2-1-0-0-10-cr01.seattle.wa.ibone.comcast.net
pos-0-4-0-0-cr01.chicago.il.ibone.comcast.net
server {
listen 80;
listen [::]:80;
listen 443 ssl spdy;
listen [::]:443 ssl spdy;
ssl_certificate /etc/nginx/ssl/7086.in.crt;
ssl_certificate_key /etc/nginx/ssl/7086.in.key;
root /var/www/msg7086/mj.7086.in/;
index index.php index.htm index.html;
diff --git a/include/functions.php-20140612-bak.php b/include/functions.php
index 74cce2b..bff85a0 100644
--- a/include/functions.php-20140612-bak.php
+++ b/include/functions.php
@@ -253,7 +253,7 @@ function formatFlv($src, $width, $height) {
return addTempCode("<object width=\"$width\" height=\"$height\"><param name=\"movie\" value=\"flvplayer.swf?file=$src\" /><param name=\"allowFullScreen\" value=\"true\" /><embed src=\"flvplayer.swf?file=$src\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"$width\" height=\"$height\"></embed></object>");
}
function format_urls($text, $newWindow = false) {
- return preg_replace_callback("/((https?|ftp|gopher|news|telnet|mms|rtsp):\/\/[^()\[\]<>\s]+)/i", create_function('$matches', "return formatUrl('$matches[1]', ".($newWindow==true ? 1 : 0).", '', 'faqlink');"), $text);
+ return preg_replace_callback("/((https?|ftp|gopher|news|telnet|mms|rtsp):\/\/[^()\[\]<>\s]+)/i", function($matches) use ($newWindow) { return formatUrl($matches[1], $newWind