Skip to content

Instantly share code, notes, and snippets.

Avatar
⌨️
<typing sounds>

Matthew Tovbin tovbinm

⌨️
<typing sounds>
View GitHub Profile
@tovbinm
tovbinm / FileAsyncIO.scala
Last active Sep 3, 2020
File Async IO for Scala
View FileAsyncIO.scala
import java.io.IOException
import java.nio.ByteBuffer
import java.nio.channels.{AsynchronousFileChannel, CompletionHandler}
import java.nio.file.Paths
import java.nio.file.StandardOpenOption._
import scala.concurrent.{ExecutionContext, Future, Promise}
import scala.util.Try
/**
@tovbinm
tovbinm / fauna-graphql-relations.gql
Last active Aug 22, 2020
FaunaDB Relations: GraphQL schemas, mutations and resulting documents
View fauna-graphql-relations.gql
****************************************************************************
**** FaunaDB Relations: GraphQL schemas, mutations and resulting documents *
****************************************************************************
**** One to One Relation ***************************************************
SCHEMA:
type User { name: String! car: Car }
type Car { plate: String! owner: User }
MUTATION:
mutation Create {
createUser(data: {
@tovbinm
tovbinm / gist:2975609
Created Jun 22, 2012
Remove the “Last login” message from the Mac OS X Terminal
View gist:2975609
Remove:
touch .hushlogin
Get it back:
rm .hushlogin
@tovbinm
tovbinm / FaunaDBTesting.scala
Last active Apr 18, 2020
FaunaDB container testing trait for Scala
View FaunaDBTesting.scala
import java.net.{ InetSocketAddress, Socket }
import java.time.Duration
import java.time.temporal.ChronoUnit.SECONDS
import java.util.concurrent.{ TimeUnit, TimeoutException }
import java.util.function.{ Consumer, Predicate }
import com.dimafeng.testcontainers.{ Container, GenericContainer }
import com.faunadb.client.FaunaClient
import org.junit.runner.Description
@tovbinm
tovbinm / Pretty git log
Last active Dec 18, 2019
Pretty git log command
View Pretty git log
1.
Paste it to the bash:
git config --global alias.lg "log --graph --pretty=format:'%C(auto)%h -%d %s %Cgreen(%cr) %C(bold blue)%an <%ae>%Creset' --abbrev-commit"
2.
Then in any git repo type: git lg
3.
Enjoy
@tovbinm
tovbinm / Linux
Created Apr 9, 2012
Increase ulimit
View Linux
1.
# vim /etc/sysctl.conf
fs.file-max = 999999
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216
net.ipv4.ip_local_port_range = 1024 65535
2.
# vim /etc/security/limits.conf
root - nofile 999999
@tovbinm
tovbinm / script.sh
Created Feb 25, 2015
Changing ulimit for running processes
View script.sh
cd /proc/<pid> && echo -n "Max open files=65535:65535" > limits
@tovbinm
tovbinm / mass_alarms.rb
Created Dec 7, 2012
Mass Alarms - a tool for creating/updating a large amount of AWS CloudWatch metric alarms
View mass_alarms.rb
require 'rubygems'
require 'aws-sdk'
puts "\nLoading instances..."
if File.exist?('instances.yaml')
instances_by_id = YAML.load_file('instances.yaml')
puts "Loaded %d instances from instances.yaml" % [instances_by_id.count]
else
instances_by_id = Hash.new
ec2 = AWS::EC2.new
@tovbinm
tovbinm / crontab
Created Feb 22, 2012
Logrotate & upload nginx logfiles to s3://bucket/dt=..../hostname.log...gz
View crontab
# Nginx - logrotate & upload to S3
0 0 * * * /usr/sbin/logrotate /etc/logrotate.d/nginx
15 0 * * * s3cmd put /var/log/nginx/access.log-`date +"\%Y\%m\%d"`.gz s3://$LOGS_BUCKET_NAME/nginx-access/`date +"dt=\%Y\%m\%d"`/`hostname -s`.access.log-`date +"\%Y\%m\%d"`.gz
@tovbinm
tovbinm / git-patch.sh
Created Dec 20, 2017
Apply git patch safely with rejects
View git-patch.sh
git format-patch HEAD~X --stdout > patch
git apply --stat patch
git apply --reject --whitespace=fix patch