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 | |
/** |
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: { |
View gist:2975609
Remove: | |
touch .hushlogin | |
Get it back: | |
rm .hushlogin |
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 |
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 |
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 |
View script.sh
cd /proc/<pid> && echo -n "Max open files=65535:65535" > limits |
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 |
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 |
View git-patch.sh
git format-patch HEAD~X --stdout > patch | |
git apply --stat patch | |
git apply --reject --whitespace=fix patch |
NewerOlder