Skip to content

Instantly share code, notes, and snippets.

View abdihaikal's full-sized avatar
💭
I may be slow to respond.

Abdi Haikal abdihaikal

💭
I may be slow to respond.
  • Singapore, Singapore
View GitHub Profile
@abdihaikal
abdihaikal / get-days-in-year.js
Last active October 5, 2016 03:38
Get Days in A Year - Date Polyfill
'use strict';
if (!Date.prototype.getDaysInYear) {
Date.prototype.getDaysInYear = function getDaysInYear(year) {
year = year ? year : this.getFullYear();
var days = 0;
for (var i = 1; i < 13; i++) {
days += new Date(year, i, 0).getDate();
}
return days;
};
#!/bin/bash
# export DBUS_SESSION_BUS_ADDRESS environment variable because cron hates me
PID=$(pgrep -u USER gnome-session-b)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
/usr/bin/gsettings set org.gnome.shell.extensions.user-theme name 'Flat-Plat'
/usr/bin/gsettings set org.gnome.desktop.interface gtk-theme 'Flat-Plat'
/usr/bin/gsettings set org.gnome.desktop.background picture-uri 'file://WALLPAPER-PATH'
/usr/bin/gsettings --schemadir ~/.local/share/gnome-shell/extensions/drop-down-terminal@gs-extensions.zzrough.org set org.zzrough.gs-extensions.drop-down-terminal background-color 'rgb(69,90,100)'

WannaCry|WannaDecrypt0r NSA-Cyberweapon-Powered Ransomware Worm

  • Virus Name: WannaCrypt, WannaCry, WanaCrypt0r, WCrypt, WCRY
  • Vector: All Windows versions before Windows 10 are vulnerable if not patched for MS-17-010. It uses EternalBlue MS17-010 to propagate.
  • Ransom: between $300 to $600. There is code to 'rm' (delete) files in the virus. Seems to reset if the virus crashes.
  • Backdooring: The worm loops through every RDP session on a system to run the ransomware as that user. It also installs the DOUBLEPULSAR backdoor. It corrupts shadow volumes to make recovery harder. (source: malwarebytes)
  • Kill switch: If the website www.iuqerfsodp9ifjaposdfjhgosurijfaewrwergwea.com is up the virus exits instead of infecting the host. (source: malwarebytes). This domain has been sinkholed, stopping the spread of the worm. Will not work if proxied (source).

update: A minor variant of the viru

@abdihaikal
abdihaikal / dotNetFx40_Full_x86_x64.bat
Created May 18, 2017 03:40
MDT 2012 Update 1 - NET Framework 4.0 installer batch script
@ECHO OFF
PUSHD %~dp0
TITLE INSTALLING NET FRAMEWORK 4.0
ECHO INSTALLING NET FRAMEWORK 4.0......................
dotNetFx40_Full_x86_x64.exe /q /norestart /ChainingPackage ADMINDEPLOYMENT
public abstract class AppDatabase extends RoomDatabase {
private static final String TAG = "AppDatabase";
private static volatile AppDatabase INSTANCE;
public static AppDatabase getInstance(Context context) {
if (INSTANCE == null) {
synchronized (AppDatabase.class) {
if (INSTANCE == null) {
INSTANCE = Room.databaseBuilder(context.getApplicationContext(), AppDatabase.class, 'appdatabase.db').build();
}
@abdihaikal
abdihaikal / is_numeric.js
Created January 19, 2019 12:16
Method checks whether its argument represents a numeric value.
function isNumeric(value) {
return !isNaN(parseFloat(value)) && isFinite(value) && 'number' === typeof value && value === Number(parseFloat(value));
}
@abdihaikal
abdihaikal / mersenne-twister.js
Created January 30, 2019 14:38 — forked from banksean/mersenne-twister.js
a Mersenne Twister implementation in javascript. Makes up for Math.random() not letting you specify a seed value.
/*
I've wrapped Makoto Matsumoto and Takuji Nishimura's code in a namespace
so it's better encapsulated. Now you can have multiple random number generators
and they won't stomp all over eachother's state.
If you want to use this as a substitute for Math.random(), use the random()
method like so:
var m = new MersenneTwister();
@abdihaikal
abdihaikal / rAF.js
Created November 17, 2019 17:02 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@abdihaikal
abdihaikal / BrowserSync and Ngrok
Created March 23, 2020 20:56
How to implementing ngrok with browser-sync
const browserSync = require('browser-sync'); // @link https://www.npmjs.com/package/browser-sync
const ngrok = require('ngrok'); // @link https://www.npmjs.com/package/ngrok
// Create BrowserSync instance
const instance = browserSync.create("Whatever-Name-You-Want");
// BrowserSYnc Options
// @link https://browsersync.io/docs/options
const options = {...}