Skip to content

Instantly share code, notes, and snippets.

;; .emacs
;; Keybindings
(define-key global-map "\C-h" 'delete-backward-char)
(define-key global-map "\C-z" 'undo)
;; Disable auto saving and backuping
(setq make-backup-files nil)
(setq auto-save-default nil)
$candidates = @(
'A',
'B',
'C',
'D',
'E',
'F'
)
$winners = @()
@saggie
saggie / check_wncry.bat
Created May 17, 2017 02:46
check_wncry.bat c:\ d:\ e:\
@echo off
set targets=mssecsvc.exe tasksche.exe .WNCRYT .WNCRY
for %%i in (%targets%) do (
for %%j in (%*) do (
echo search %%j in *%%i
start /B where /R %%j *%%i
)
)
@saggie
saggie / pom.xml
Created June 1, 2017 02:33
How to generate a "jar-with-dependencies"
...
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.sample.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
@saggie
saggie / Main.java
Last active June 11, 2017 10:54
A simple Kafka (sender and receiver) sample code in Java
package sample;
import java.util.Arrays;
import java.util.Date;
import java.util.Properties;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.clients.producer.KafkaProducer;
@saggie
saggie / reset-kafka-offset.py
Created June 30, 2017 07:38
Reset a Kafka offset by Python
import kafka
from kafka import TopicPartition
from kafka.structs import OffsetAndMetadata
KAFKA_SERVER = '__KAFKA_SERVER__:9092'
GROUP_ID = 'our-group'
TOPIC_NAME = 'our-topic'
PARTITION_NUMBER = 0
@saggie
saggie / setup_jetty.sh
Last active July 6, 2017 09:19
Setup Jetty
wget http://central.maven.org/maven2/org/eclipse/jetty/jetty-distribution/8.2.0.v20160908/jetty-distribution-8.2.0.v20160908.tar.gz
tar -zxvf jetty-distribution-8.2.0.v20160908.tar.gz
mv jetty-distribution-8.2.0.v20160908 /opt/jetty
sudo sh -c 'echo JETTY_HOME="/opt/jetty" > /etc/default/jetty'
sudo sh -c 'echo "TMPDIR=/opt/jetty/temp" >> /etc/default/jetty'
mv myapp.war /opt/jetty/webapps/
/opt/jetty/bin/jetty.sh start
# verify
wget localhost:8080/myapp/
@saggie
saggie / .md
Last active July 11, 2017 03:17
Setup DNS servers for CentOS 7
  1. nmtui
    1. Edit a connection
    2. ens160
    3. DNS servers <Add...>
      • 111.111.111.111
      • 222.222.222.222
    4. <OK>
    5. <BACK>
    6. QUIT
@saggie
saggie / Check-HotFixApplied
Created July 14, 2017 01:58
Check whether or not the target security patches (KBxxxxx) are applied (by PowerShell)
Get-WMIObject Win32_QuickFixEngineering | where { $_.HotFixId -match '4025337|4025341' }
@saggie
saggie / .md
Last active July 14, 2017 04:27
Install and setup chrony (NTP client)
  1. yum -y install chrony

  2. nano /etc/chrony.conf

    server 111.111.111.111 iburst
    #server 0.centos.pool.ntp.org iburst
    #server 1.centos.pool.ntp.org iburst
    #server 2.centos.pool.ntp.org iburst
    #server 3.centos.pool.ntp.org iburst