Skip to content

Instantly share code, notes, and snippets.

View tovbinm's full-sized avatar
⌨️
<typing sounds>

Matthew Tovbin tovbinm

⌨️
<typing sounds>
View GitHub Profile
@tovbinm
tovbinm / fauna-graphql-relations.gql
Last active March 6, 2022 14:38
FaunaDB Relations: GraphQL schemas, mutations and resulting documents
****************************************************************************
**** 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: {
1. Open terminal inside your virtual machine and run:
sudo dd if=/dev/zero of=EMPTY bs=1M
sudo rm ./EMPTY
This will zeroify all the empty blocks on your disk.
2. Shutdown you virtual box.
3. Check what type of virtual drive do you have: VMDK or VDI. VirtualBox shrinking works only with VDI files.
If you have a VDI file, proceed to the last step, otherwise you'll need to perform an additional step of converting your VMDK file
@tovbinm
tovbinm / FileAsyncIO.scala
Last active March 15, 2021 10:43
File Async IO for 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 / gist:2975609
Created June 22, 2012 22:47
Remove the “Last login” message from the Mac OS X Terminal
Remove:
touch .hushlogin
Get it back:
rm .hushlogin
@tovbinm
tovbinm / FaunaDBTesting.scala
Last active April 18, 2020 02:00
FaunaDB container testing trait for 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 December 18, 2019 07:10
Pretty git log command
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 April 9, 2012 20:04
Increase ulimit
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 February 25, 2015 17:25
Changing ulimit for running processes
cd /proc/<pid> && echo -n "Max open files=65535:65535" > limits
@tovbinm
tovbinm / mass_alarms.rb
Created December 7, 2012 19:57
Mass Alarms - a tool for creating/updating a large amount of AWS CloudWatch metric alarms
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 February 22, 2012 01:10
Logrotate & upload nginx logfiles to s3://bucket/dt=..../hostname.log...gz
# 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