Skip to content

Instantly share code, notes, and snippets.

View NamPNQ's full-sized avatar
🤒
Out sick

Nam PHAM NamPNQ

🤒
Out sick
  • Ho Chi Minh
View GitHub Profile
@pathikrit
pathikrit / NQueen.scala
Last active January 19, 2023 21:30
O(n!) solution to the n-Queen puzzle (https://en.wikipedia.org/wiki/Eight_queens_puzzle)
/**
* Solves the n-Queen puzzle in O(n!)
* Let p[r] be the column of the queen on the rth row (must be exactly 1 queen per row)
* There also must be exactly 1 queen per column and hence p must be a permuation of (0 until n)
* There must be n distinct (col + diag) and n distinct (col - diag) for each queen (else bishop attacks)
* @return returns a Iterator of solutions
* Each solution is an array p of length n such that p[i] is the column of the queen on the ith row
*/
def nQueens(n: Int): Iterator[Seq[Int]] =
(0 until n)
@megastef
megastef / sematext-agent-docker.nomad
Last active May 21, 2017 14:28
Monitoring and Logging for all Docker containers on Nomad by HashiCorp
# Run Job Definition: nomad run sematext-agent-docker.nomad
# https://www.hashicorp.com/blog/nomad.html
# More Info: https://hub.docker.com/r/sematext/sematext-agent-docker/
# http://blog.sematext.com/2015/12/15/docker-logging-partner-sematext-logsene/
job "sematext-agent-docker" {
# set your region here
region = "global"
# Mandatory, parameter pls. change!
datacenters = ["us-west-1"]
# run this job globally
<!DOCTYPE html>
<html><head>
<title>Obfuscated name remapper</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body {
background: white;
color: black;
font-family: "Trebuchet MS",Helvetica,Tahoma,Arial,sans-serif;
font-size: 90.01%;
@ba0f3
ba0f3 / init.el
Last active January 13, 2016 15:58
Emacs init file
(ido-mode 1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
;(menu-bar-mode -1)
(show-paren-mode 1)
(eldoc-mode 1)
(defalias 'yes-or-no-p 'y-or-n-p)
(setq make-backup-files nil)
@panurge-ws
panurge-ws / gist:525caef640784a487aa2
Last active May 20, 2016 10:38
A Videgular plugin to emulate background-size CSS property for video (see comment below).
/*
* vg-bkg-size
* A Videogular plugin to emulate background-size CSS property for video: "cover" or "contain"
*
* Use:
* <videogular vg-bkg-size="cover" center="true"></videogular>
* vg-bkg-size => "cover" or "contain"
* center => true or false
*
* Copyright (c) 2014 Panurge Web Studio
@tsolar
tsolar / laravel-subdirectory.conf
Last active February 27, 2024 03:36
Laravel in subdirectory nginx example
server {
client_body_in_file_only clean;
client_body_buffer_size 32K;
client_max_body_size 300M;
sendfile on;
send_timeout 300s;
# Port that the web server will listen on.
#listen 80;
@ndarville
ndarville / webm.md
Last active September 30, 2023 18:56
4chan’s guide to converting GIF to WebM - https://boards.4chan.org/g/res/41212767

Grab ffmpeg from https://www.ffmpeg.org/download.html

It's a command line tool which means you will have to type things with your keyboard instead of clicking on buttons.

The most trivial operation would be converting gifs:

ffmpeg -i your_gif.gif -c:v libvpx -crf 12 -b:v 500K output.webm
  • -crf values can go from 4 to 63. Lower values mean better quality.
  • -b:v is the maximum allowed bitrate. Higher means better quality.
@wbroek
wbroek / genymotionwithplay.txt
Last active February 12, 2024 03:22
Genymotion with Google Play Services for ARM
NOTE: Easier way is the X86 way, described on https://www.genymotion.com/help/desktop/faq/#google-play-services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 6.0 (https://www.androidfilehost.com/?fid=24052804347835438 - benzo-gapps-M-20151011-signed-chroma-r3.zip)
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161891406 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
@EyalAr
EyalAr / client.py
Created December 11, 2013 18:17
Demo code for my post about python's blocking stream reading functions.
from subprocess import Popen, PIPE
from time import sleep
# run the shell as a subprocess:
p = Popen(['python', 'shell.py'],
stdin = PIPE, stdout = PIPE, stderr = PIPE, shell = False)
# issue command:
p.stdin.write('command\n')
# let the shell output the result:
sleep(0.1)
#!/usr/bin/env bash
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz
mkdir vim && tar xzvf vim.tar.gz -C vim
export PATH=$PATH:/app/vim/bin