Skip to content

Instantly share code, notes, and snippets.

@rcanepa
rcanepa / gist:535163dc249539912c25
Last active May 2, 2024 07:08
Activate pg_stat_statements on PostgreSQL
1) Edit file postgresql.conf and add the next 3 lines (any where):
shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.max = 10000
pg_stat_statements.track = all
2) Restart PostgreSQL
3) Execute the next command on psql, pgAdmin or similar:
@romanlehnert
romanlehnert / truncate_rails_tables.rb
Created September 17, 2013 15:54
Truncate all tables in rails
ActiveRecord::Base.establish_connection
ActiveRecord::Base.connection.tables.each do |table|
next if table == 'schema_migrations'
case ActiveRecord::Base.connection.adapter_name.downcase.to_sym
when :mysql2 || :postgresql
ActiveRecord::Base.connection.execute("TRUNCATE #{table}")
when :sqlite
ActiveRecord::Base.connection.execute("DELETE FROM #{table}")
end
@alexpsi
alexpsi / asyncChunkedMap.js
Created February 25, 2017 20:31
Like Promise.all but executed in chunks, so you can have some async concurrency control.
const chunks = (arr, chunkSize) => {
let results = [];
while (arr.length) results.push(arr.splice(0, chunkSize));
return results;
};
module.exports = (xs, f, concurrency) => {
if (xs.length == 0) return Promise.resolve();
return Promise.all(chunks(xs, concurrency).reduce(
(acc, chunk) => acc.then(() => Promise.all(chunk.map(f))),

DigitalOcean Promo Code 2024 / $200 - $400 / 1-Year Valid

DigitalOcean offers substantial discounts for new users via exclusive promo codes. These codes provide free credits ranging from $10 to $200 to experience DigitalOcean's cloud services.

This guide provides:

  • A list of currently active and latest DigitalOcean promo codes with applicable credit amounts, services, expiry dates and terms.
  • Step-by-step instructions to easily redeem codes as a new user, along with tips to maximize promotional savings.
  • One special offer that will give you free credits that is valid for 1 year.
@ipan
ipan / diff-jq.md
Created January 16, 2018 04:47
compare two JSONs with jq #json #jq
@mignonstyle
mignonstyle / markdown-cheatsheet.md
Last active May 2, 2024 07:01
Markdown記法 チートシート

Block Elements ## Headers 見出し 先頭に#をレベルの数だけ記述します。 ```

見出し1

見出し2

見出し3

見出し4

見出し5
見出し6
## 見出し2
### 見出し3
#### 見出し4
##### 見出し5
###### 見出し6 ## Block 段落 空白行を挟むことで段落となります。 ```
段落1
(空行)
段落2
``` 段落1 段落2 ## Br 改行 改行の前に半角スペース` `を2つ記述します。 ```
hoge
fuga(スペース2つ)
piyo
``` hoge
fuga piyo ## Blockquotes 引用 先頭に`>`を記述します。ネストは`>`を多重に記述します。 ```
> 引用 > 引用
>> 多重引用
``` > 引用 > 引用
>> 多重引用 ## Code コード `` `バッククオート` `` 3つ、あるいはダッシュ`~`3つで囲みます。 ```
print 'hoge'
``` ```
print 'hoge'
``` ### インラインコード `` `バッククオート` `` で単語を囲むとインラインコードになります。 ```
これは `インラインコード`です。
``` これは `インラインコード`です。 ## pre 整形済みテキスト 半角スペース4個もしくはタブで、コードブロックをpre表示できます ``` class Hoge def hoge print 'hoge' end end
``` class Hoge def hoge print 'hoge' end end ## Hr 水平線 アンダースコア`_` 、アスタリスク`*`、ハイフン`-`などを3つ以上連続して記述します。 ```
hoge
***
hoge
___
hoge
---
``` hoge
***
hoge
___
hoge
--- # Lists ## Ul 箇条書きリスト ハイフン`-`、プラス`+`、アスタリスク`*`のいずれかを先頭に記
@GloriousEggroll
GloriousEggroll / de-anarchy.sh
Created May 7, 2018 20:22
A quick bash script to remove anarchy linux branding post-install
#!/bin/bash
sed -i -e 's/Anarchy/Arch/g' /etc/lsb-release
sed -i -e 's/Anarchy/Arch/g' /etc/os-release
sed -i -e 's/anarchy/arch/g' /etc/os-release
sed -i -e 's/arch-linux/www.archlinux/g' /etc/os-release
echo 'SUPPORT_URL="https://bbs.archlinux.org/"' >> /etc/os-release
echo 'BUG_REPORT_URL="https://bugs.archlinux.org/"' >> /etc/os-release
cp /etc/os-release /usr/lib/os-release
head -n -2 /etc/lightdm/lightdm-gtk-greeter.conf > lightdm-gtk-greeter.conf
mv lightdm-gtk-greeter.conf /etc/lightdm/
@pixeldevsio
pixeldevsio / HumanMade S3 Digital Ocean Instructions
Last active May 2, 2024 06:57
Use HumanMade S3 plugin with Digital Ocean Spaces
These are the two steps you need to take to get S3 to work with Digital Ocean Spaces.
https://github.com/humanmade/S3-Uploads
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active May 2, 2024 06:57
set -e, -u, -o, -x pipefail explanation