Skip to content

Instantly share code, notes, and snippets.

View merthmagic's full-sized avatar
🎯
Focusing

Yiming merthmagic

🎯
Focusing
  • Remote
  • Suzhou, China
View GitHub Profile
@merthmagic
merthmagic / webp2png.py
Last active August 25, 2023 05:06
convert WEBP image to PNG format and resize if necessary
from PIL import Image
def webp_to_png(input_path, output_path, size=None):
# 打开webp文件
img = Image.open(input_path)
if size is None:
pass
# 重新调整图片的大小
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],

Download CMake from: https://cmake.org/download/

wget https://cmake.org/files/v3.12/cmake-3.12.3.tar.gz

Compile from source and install

tar zxvf cmake-3.*
cd /opt
wget http://apache-mirror.rbc.ru/pub/apache/kafka/0.10.1.0/kafka_2.11-0.10.1.0.tgz
tar xvzf kafka_2.11-0.10.1.0.tgz
ln -s kafka_2.11-0.10.1.0/ kafka
vi /etc/systemd/system/kafka-zookeeper.service
[Unit]
Description=Apache Zookeeper server (Kafka)
Documentation=http://zookeeper.apache.org
#include <unistd.h>
#include <stdio.h>
void print_tty(char *name,FILE *f){
printf("%s (fileno %d): ",name,fileno(f));
if(isatty(fileno(f)))
printf("TTY %s\n",ttyname(fileno(f)));
else
printf("not a TTY\n");
}
@merthmagic
merthmagic / gitlab.conf
Created June 11, 2019 08:15 — forked from sameersbn/gitlab.conf
Nginx reverse proxy configuration for GitLab
upstream gitlab {
server 172.17.42.1:10080 fail_timeout=0;
}
# let gitlab deal with the redirection
server {
listen 80;
server_name git.example.com;
server_tokens off;
root /dev/null;
@merthmagic
merthmagic / MyClass.cs
Created January 19, 2019 03:58
round-robin load balance algorithm C# demo
using System;
using System.Collections.Generic;
using RoundRobin;
public class MyClass
{
public static void RunSnippet()
{
List<Node> servers = new List<Node>();
servers.Add(new Node("serv","urlA",1));
@merthmagic
merthmagic / Node.java
Created July 13, 2018 04:02 — forked from EvaGL/Node.java
Concurrent T-Tree
import java.util.Arrays;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
public class Node {
static final int MIN_ELEMENTS = 30, MAX_ELEMENTS = 2 * MIN_ELEMENTS;
private int[] data;
private int len;
@merthmagic
merthmagic / Program.cs
Created May 4, 2017 11:19
oracle 10g 在使用 odp.net 使用TransactionScope时提升为分布式事务的问题
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Transactions;
using Oracle.ManagedDataAccess.Client;
namespace OrclTransaction
{
@merthmagic
merthmagic / gulpfile.js
Created January 29, 2016 02:40
gulpfile template
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');
var notify = require('gulp-notify');
var rename = require('gulp-rename');
var sass = require('gulp-ruby-sass');
var autoprefixer = require('gulp-autoprefixer');
var minifycss = require('gulp-minify-css');