Skip to content

Instantly share code, notes, and snippets.

@mocchira
mocchira / curl_range.md
Last active February 17, 2025 22:25
HTTP GET with Range header by curl
  • normal(explicitly specified start AND end)
  curl -v -X GET -H "range: bytes=1-8" http://localhost:8080/bbb/test
  • specified ONLY start(end will be specified at the end of file)
  curl -v -X GET -H "range: bytes=10-" http://localhost:8080/bbb/test
  • specified ONLY one negative value(last N bytes of file will be retrieved)
@katjunior
katjunior / oracle_sql_text_spid.sql
Created September 18, 2013 16:00
Oracle - Select Sql Text from System Process ID
select s.sql_text,s.sql_fulltext from v$sql s
where sql_id in (SELECT A.SQL_ID FROM V$SESSION A,V$PROCESS B
WHERE A.PADDR=B.ADDR AND B.SPID='6495')
@kdabir
kdabir / mac_setup.md
Last active November 24, 2022 21:39
Clean Setup on Mac

Cleaning up the mac

Before formatting/wiping out all the data

@thomasfr
thomasfr / autossh.service
Last active November 18, 2024 03:37
Systemd service for autossh
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
@sokratisg
sokratisg / sysctl.conf
Last active January 5, 2024 00:03
Tuned sysctl.conf for use by CentOS/RHEL 6.x or later
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Turn on execshield
# 0 completely disables ExecShield and Address Space Layout Randomization
# 1 enables them ONLY if the application bits for these protections are set to “enable”
# 2 enables them by default, except if the application bits are set to “disable”
# 3 enables them always, whatever the application bits
@hfeeki
hfeeki / imgcompare.py
Last active September 8, 2022 01:11
利用opencv做图片相似度比较
# coding: utf8
'''
对于图片相似度比较有很多方法,我们这以RGB直方图为例。
我们以一种规则,使得每个图片生成一组描述的特征向量。
opencv的直方图比较函数我们可以巧妙的利用,其有若干比较规则,但只支持直方图的数据结构,我们可以将特征向量拟合成直方图的数据结构,然后使用其的相似度比较函数。
具体的数学计算方法有兴趣的可以看opencv的官方教程,这里我们期望生成百分比形式的相似度参数,所以使用CV_COMP_CORREL
以下是代码,以python编写
'''
import cv2.cv as cv
@morhekil
morhekil / nginx.conf
Created August 14, 2014 12:18
Full request/response body logging in nginx
http {
log_format bodylog '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time '
'<"$request_body" >"$resp_body"';
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua '
@amatellanes
amatellanes / celery.sh
Last active March 25, 2025 18:02
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
@pankaj28843
pankaj28843 / Make soffice command of Libreoffice work on Mac OS X.md
Last active February 12, 2025 06:47
Make soffice command of Libreoffice work on Mac OS X

Deprecated Notice

This script, originally created on April 29, 2015, addressed a different behavior of LibreOffice installation on macOS at that time. However, it is now outdated and no longer relevant. Please refer to the latest comments for updated information, as much has changed over the past 8–9 years.


Quick Start

sudo curl https://gist.githubusercontent.com/pankaj28843/3ad78df6290b5ba931c1/raw/soffice.sh &gt; /usr/local/bin/soffice &amp;&amp; sudo chmod +x /usr/local/bin/soffice
@somebox
somebox / osx-setup.sh
Last active December 11, 2021 13:05 — forked from foz/osx-setup.sh.md
Set up an OSX machine from zero to awesome. Uses Homebrew (and cask, fonts, etc). Focused on Ruby/Rails development, includes rvm, xquartz, editor fonts, sublime text, and many tools.
#!/bin/bash
# A script to set up a new mac. Uses bash, homebrew, etc.
# Focused for ruby/rails development. Includes many utilities and apps:
# - homebrew, rvm, node
# - quicklook plugins, terminal fonts
# - browsers: chrome, firefox
# - dev: iterm2, sublime text, postgres, chrome devtools, etc.
# - team: slack, dropbox, google drive, skype, etc