Skip to content

Instantly share code, notes, and snippets.

View yakjuly's full-sized avatar

Ankun Yu yakjuly

View GitHub Profile
@dejadejade
dejadejade / img2pdf.go
Created April 26, 2020 20:38
images to pdf
package main
import (
"archive/zip"
"bytes"
"flag"
"fmt"
"image"
"image/color"
_ "image/jpeg"
@skout23
skout23 / logs_insights_queries.txt
Created February 11, 2019 19:48
Scratch Pad ideas for Cloudtrail queries using AWS Cloudwatch Logs Insights
```
filter eventName="ConsoleLogin"
| stats count(*) as eventCount by userIdentity.userName, sourceIPAddress
| sort eventCount desc
filter not sourceIPAddress =~ /^(?i)123.123.123.123/ and userIdentity.userName =~/^(?i)\w/
| stats count(*) as eventCount by eventName, userIdentity.userName, sourceIPAddress
| sort eventCount desc
filter eventName="ConsoleLogin"
@valyala
valyala / README.md
Last active March 20, 2025 08:44
Optimizing postgresql table for more than 100K inserts per second

Optimizing postgresql table for more than 100K inserts per second

  • Create UNLOGGED table. This reduces the amount of data written to persistent storage by up to 2x.
  • Set WITH (autovacuum_enabled=false) on the table. This saves CPU time and IO bandwidth on useless vacuuming of the table (since we never DELETE or UPDATE the table).
  • Insert rows with COPY FROM STDIN. This is the fastest possible approach to insert rows into table.
  • Minimize the number of indexes in the table, since they slow down inserts. Usually an index on time timestamp with time zone is enough.
  • Add synchronous_commit = off to postgresql.conf.
  • Use table inheritance for fast removal of old data:
@pauly4it
pauly4it / androidPurchaseReceipt.json
Created June 11, 2015 04:02
All code for Validating Android In-App Purchases With Laravel blog post: http://blog.goforyt.com/validating-android-app-purchases-laravel/
{
"receipt": {
"type": "android-playstore",
"id": "12345678901234567890.1234567890123456",
"purchaseToken": "purchase token goes here",
"receipt": "{"orderId":"12345678901234567890.1234567890123456","packageName":"com.example.app","productId":"com.example.app.product","purchaseTime":1417113074914,"purchaseState":0,"purchaseToken":"purchase token goes here"}",
"signature": "signature data goes here"
}
}
@marianposaceanu
marianposaceanu / linux_fun.md
Last active March 16, 2025 22:31
How to have some fun using the terminal.

Linux fun-o-matic

How to have some fun using the terminal.

  1. Install cowsay [0] via : sudo apt-get install cowsay
  2. Install fortune [1] via : sudo apt-get install fortune
  3. Make sure you have Ruby installed via : ruby -v
  4. Install the lolcat [2] via : gem gem install lolcat
  5. Profit!
@funny-falcon
funny-falcon / changes.md
Last active August 15, 2024 15:13
Performace patch for ruby-1.9.3-p327

Changes:

  • this version includes backport of Greg Price's patch for speedup startup http://bugs.ruby-lang.org/issues/7158 .

    ruby-core prefers his way to do thing, so that I abandon cached-lp and sorted-lf patches of mine.

  • this version integrates 'array as queue' patch, which improves performance when push/shift pattern is heavily used on Array.

    This patch is accepted into trunk for Ruby 2.0 and last possible bug is found by Yui Naruse. It is used in production* for a couple of months without issues even with this bug.

@ktheory
ktheory / 0001-Whitespace-tabs-to-spaces.patch
Created June 25, 2012 13:36
Patch to unicorn example init script: better upgrade task
From 233f504a39aca6e8b2d9332ef324b4c5cc397eca Mon Sep 17 00:00:00 2001
From: Aaron Suggs <[email protected]>
Date: Fri, 6 Apr 2012 18:35:38 -0400
Subject: [PATCH 1/2] Whitespace: tabs to spaces
---
examples/init.sh | 90 +++++++++++++++++++++++++++---------------------------
1 files changed, 45 insertions(+), 45 deletions(-)
diff --git a/examples/init.sh b/examples/init.sh
@nzifnab
nzifnab / jqueryTemplate.js
Created May 7, 2011 02:23 — forked from tosh/jammit-jquery-tmpl.coffee
jquery tmpl templating function for use with jammit
// It's more advisable to store the compiled version of the jQuery template in JST,
// And then use a separate function that renders on a per-use basis from that pre-compiled template.
function jqueryCacheTemplate(templateString){
return $.template(null, templateString);
}
function jqueryTemplate(name){
return $.tmpl(JST[name], arguments[0], arguments[1]);
}