Skip to content

Instantly share code, notes, and snippets.

@c80609a
c80609a / integer.rb
Created November 8, 2016 11:38 — forked from pithyless/integer.rb
Ruby Integer::MAX and Integer::MIN
class Integer
N_BYTES = [42].pack('i').size
N_BITS = N_BYTES * 16
MAX = 2 ** (N_BITS - 2) - 1
MIN = -MAX - 1
end
p Integer::MAX #=> 4611686018427387903
p Integer::MAX.class #=> Fixnum
p (Integer::MAX + 1).class #=> Bignum
class BinaryNode:
__slots__ = ("value", "left", "right")
def __init__(self, value=None, left=None, right=None):
self.value = value
self.left = left
self.right = right
def __repr__(self):
return f"<BinaryNode value={self.value}; {1 if self.left else 0 + 1 if self.right else 0} children>"
@c80609a
c80609a / convert2voice.sh
Created September 12, 2023 06:44 — forked from samoshkin/convert2voice.sh
Google Text-to-Speech API example
#!/bin/bash
text=$(cat -)
request="{
'input':{
'ssml':'<speak>$text</speak>'
},
'voice':{
'languageCode':'en-gb',
'name':'en-GB-Wavenet-D',
@c80609a
c80609a / jira_ticket_status_diagram_in_mermaid.mmd
Created September 12, 2023 06:36 — forked from samoshkin/jira_ticket_status_diagram_in_mermaid.mmd
JIRA ticket state diagram written in Mermaid DSL
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@c80609a
c80609a / socket-io-and-redux-saga-integration.js
Created September 12, 2023 06:32 — forked from samoshkin/socket-io-and-redux-saga-integration.js
Socket.IO and redux-saga integration. Connection management
import { io } from 'socket.io-client';
import * as SentrySDK from '@sentry/react';
import {
call,
fork,
takeEvery,
put,
race,
take,
} from 'redux-saga/effects';
@c80609a
c80609a / research.md
Created September 9, 2023 15:08 — forked from Code-Hex/research.md
Research performance nginx per configuration

wrk -c 100 -t 4 -d 10 http://127.0.0.1:8080/

Default configuration

nginx.conf

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
@c80609a
c80609a / README.md
Created July 14, 2023 15:39 — forked from adevil5/README.md
Create Postgres Roles

Create Postgres Roles

read_access

Read all data (tables, views, sequences), as if having SELECT rights on those objects, and USAGE rights on all user-created schemas.

  1. Replace db_name with the relevant database name.
  2. Run the Database section of the script.
#!/bin/bash
################################################################################
#
# Helper variables to print text using some colors.
#
################################################################################
# Restore to default colours
RESTORE='\033[0m'
@c80609a
c80609a / fb-base-code-example.js
Created March 13, 2023 08:51 — forked from dbradley/fb-base-code-example.js
Facebook Pixel Standard Events
<!-- Facebook Pixel Code Example -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '1234567890');
fbq('track', "PageView");
[Unit]
Description=Download IP Geolocation Database from Maxmind.com
[Service]
Type=oneshot
WorkingDirectory=/tmp
ExecStart=/bin/sh -c "\
mkdir -p /home/core/ip_database \
curl -O http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz ; \
gunzip GeoLite2-City.mmdb.gz ; \
curl -O http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.md5 ; \