Skip to content

Instantly share code, notes, and snippets.

View soardex's full-sized avatar

Edward Fitz Bucud Abucay soardex

View GitHub Profile
@soardex
soardex / gist:c670eaebcf1fcfc1733b009131a96a64
Created December 8, 2016 10:04
Equilibrium Interpolation
import scala.collection.JavaConverters._
object Solution {
def solution(a: Array[Int]): Int = {
var sum = 0
for (i <- 0 to (a.length - 1)) {
sum += a(i)
}
var sum_left = 0
@soardex
soardex / gist:4f1eb399c4c603a2d5fc7a98bfe5c86b
Created December 7, 2016 05:04
Creating Patch And Applying Patch In Git
git diff --no-prefix master > diff.patch
git checkout master patch -p0 < diff.patch
rpm2cpio filename.rpm | cpio -idmv
sudo yum install rpm-build
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS,TMP}
touch ~/.rpmmacros
~~~
%packager ffimusic
%_topdir /home/ffimusic/rpmbuild
%_tmppath /home/ffimusic/rpmbuild/TMP
~~~
It is possible to go back to a more classic iptables setup. First, stop and mask the firewalld service:
systemctl stop firewalld
systemctl mask firewalld
Then, install the iptables-services package:
yum install iptables-services
Enable the service at boot-time:
systemctl enable iptables
@soardex
soardex / gist:338eaecb63dc256180da
Created January 23, 2016 11:37
My Vim Cheatsheet
# working with args
:args - list
:n - next
:prev - previous
:n [filename] - open new file
# working with tabs
:tabe [filename] - open new tab
:tabn - next
:tabp - previous
@soardex
soardex / gist:79700587cf706fcad4fa
Created January 23, 2016 05:45
Saving Sessions On Vim
# Saving Sessions
:mksession ~/cs.vim
# Loading Sessions
:source ~/cs.vim
@soardex
soardex / gist:1a59c2cee24e6c9329cd
Created January 23, 2016 05:32
Vim Save On Read-Only File
# set autoread so there are no interactive Load File option
:set ar
# save the command using tee and discard tee echo
:w !sudo tee % > /dev/null
@soardex
soardex / gist:cf30a8d0673ba1e9f4d3
Created January 22, 2016 11:05
Awk Internal Variables
FILENAME: References the current input file.
FNR: References the number of the current record relative to the current input file. For instance, if you have two input files, this would tell you the record number of each file instead of as a total.
FS: The current field separator used to denote each field in a record. By default, this is set to whitespace.
NF: The number of fields in the current record.
NR: The number of the current record.
OFS: The field separator for the outputted data. By default, this is set to whitespace.
ORS: The record separator for the outputted data. By default, this is a newline character.
RS: The record separator used to distinguish separate records in the input file. By default, this is a newline character.
@soardex
soardex / gist:d9d3967832730bf4f5dd
Created January 18, 2016 10:19
My Most Used Docker Commands
# build docker config
docker build -t [name:tag] .
# inspecting containers
docker inspect [container-id]
# create an image from a container
docker commit -a [author] -m [message] [container-id] [name:tag]
# compare docker container with image