Skip to content

Instantly share code, notes, and snippets.

View whatvn's full-sized avatar

Hung whatvn

View GitHub Profile
@whatvn
whatvn / gist:3c9571325dd4cb5bc6b10f344692e031
Created April 24, 2024 08:16
The CUDA compiler identification is unknown
Collecting llama-cpp-python
Using cached llama_cpp_python-0.2.64.tar.gz (37.4 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Collecting jinja2>=2.11.3
Using cached Jinja2-3.1.3-py3-none-any.whl (133 kB)
Collecting diskcache>=5.6.1
Using cached diskcache-5.6.3-py3-none-any.whl (45 kB)
@whatvn
whatvn / scale
Created October 9, 2014 07:10
scale
// scale video
static AVFrame* scale_encode_write_frame(AVFrame *frame, int src_w, int src_h,
int dst_w, int dst_h) {
int ret = 0;
AVFrame *scale_frame;
scale_frame = av_frame_alloc();
if (!scale_frame) {
av_log(NULL, AV_LOG_DEBUG, "Cannot get allocate scale frame\n");
return frame;
}
/*
* Fancy ID generator that creates 20-character string identifiers with the
* following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't
* collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters
* that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in
@whatvn
whatvn / timeout.sh
Created February 24, 2012 09:19
kill a proc after timeout
#!/bin/bash
#
# The Bash shell script executes a command with a time-out.
# Upon time-out expiration SIGTERM (15) is sent to the process. If the signal
# is blocked, then the subsequent SIGKILL (9) terminates it.
#
# Based on the Bash documentation example.
# Hello Chet,
# please find attached a "little easier" :-) to comprehend
#!/usr/bin/env python
try:
import simplejson as json
except:
import json
import urllib2
class ServerStatistics(object):
def __init__(self):
table ip filter {
chain input {
type filter hook input priority 0; policy accept;
}
chain output {
type filter hook output priority 0; policy accept;
}
chain forward {
net.netfilter.nf_conntrack_max = 1048576
net.netfilter.nf_conntrack_tcp_be_liberal = 0
net.netfilter.nf_conntrack_tcp_loose = 0
net.netfilter.nf_conntrack_tcp_max_retrans = 3
net.netfilter.nf_conntrack_tcp_timeout_close = 2
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 2
net.netfilter.nf_conntrack_tcp_timeout_established = 120
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 2
net.netfilter.nf_conntrack_tcp_timeout_last_ack = 10
net.netfilter.nf_conntrack_tcp_timeout_max_retrans = 300
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* Created by Hung on 4/27/17.
*/
public class ListOperator {
#!/usr/bin/python
"""WSGI server example"""
from __future__ import print_function
from gevent.pywsgi import WSGIServer
import gevent
import sys
from time import *
from gevent.monkey import patch_all; patch_all()
# compile php
./configure '--prefix=/apps/php-7.0.13' '--disable-all' '--with-libdir=lib64' '--enable-ctype' '--with-curl' '--enable-libxml' '--with-mysqli' '--with-pcre-regex' '--with-iconv' '--with-config-file-path=/abserver/php-7.0.13/etc' '--with-config-file-scan-dir=/abserver/php-7.0.13/etc/php.d' '--enable-maintainer-zts' '--enable-fpm' '--enable-simplexml' '--enable-session' '--enable-xml' '--with-openssl' '--enable-dom' '--enable-json' '--enable-hash' '--enable-opcache' '--enable-phar' '--enable-filter' '--with-zlib'
make -j 8 && make install
# compile php-cpp
export PATH=$PATH:/apps/php-7.0.13/bin