Skip to content

Instantly share code, notes, and snippets.

View andirkh's full-sized avatar
💪
do our very best to produce software we can be proud of

Andi R. Hermawan andirkh

💪
do our very best to produce software we can be proud of
  • Java Island, Indonesia
View GitHub Profile
@andirkh
andirkh / downloadurlinxml.py
Created January 16, 2019 13:19
python download url from xml
import re
file = "./wordpress.xml"
regex = "(?:http\:|https\:)?\/\/.*\.(?:png|jpg)"
f = open(file, "r").read()
# array
url = re.findall(regex, f)
newfile = open("./download.txt","w")
@andirkh
andirkh / tinderfun.js
Created May 2, 2019 18:01
Tinder Always Swipe Right 🤣🔥
// Inspect element (f12) then add `sss` class into `like` button
// In the browser's console, copy and paste this code below:
setInterval(() => {
const swipe = document.getElementsByClassName('sss');
swipe[0].click()
}, 3000)
@andirkh
andirkh / changelog.sh
Created May 6, 2019 15:16
How to Changelog
github_changelog_generator --future-release v1.2.3 --since-tag v1.2.2 --token yourhashtoken
@andirkh
andirkh / simulate-https.md
Last active May 16, 2019 05:50
How to simulate https for geolocation testing in local machine

Create file server.crt file along side with server.js. Here's the code:

-----BEGIN CERTIFICATE-----
MIIDljCCAn6gAwIBAgIJAMkPpczHrXbcMA0GCSqGSIb3DQEBCwUAMA0xCzAJBgNV
BAYTAklEMB4XDTE5MDQyNzAyMTQyMVoXDTIwMDkwODAyMTQyMVowgawxCzAJBgNV
BAYTAlVTMRQwEgYDVQQIDAtSYW5kb21TdGF0ZTETMBEGA1UEBwwKUmFuZG9tQ2l0
eTEbMBkGA1UECgwSUmFuZG9tT3JnYW5pemF0aW9uMR8wHQYDVQQLDBZSYW5kb21P
cmdhbml6YXRpb25Vbml0MSAwHgYJKoZIhvcNAQkBFhFoZWxsb0BleGFtcGxlLmNv
bTESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
CgKCAQEA8f+KjOlfnf8pYejo6PP7zEeAFDkz2A53UolVsqoOLHnl8vUU3m9FTfQx
function TimezoneDetect(){
var dtDate = new Date('1/1/' + (new Date()).getUTCFullYear());
var intOffset = 10000;
var intMonth;
var intHoursUtc;
var intHours;
var intDaysMultiplyBy;
// Go through each month to find the lowest offset to account for DST
for (intMonth=0;intMonth < 12;intMonth++){
@andirkh
andirkh / reducer.template.js
Last active March 27, 2021 21:39
Template for testing reducer
import ReducerName, {
initialState,
} from '#src/containers/ContainerName/reducer';
import {
...
} from '#src/containers/ContainerName/constants';
describe('ReducerName reducer', () => {
const initialStateJS = initialState.toJS();
import React, { memo, forwardRef, PureComponent } from 'react';
import { node } from 'prop-types';
import { FixedSizeList, areEqual } from 'react-window';
import memoize from 'memoize-one';
const Row = memo(({ data = [], index, style }) => {
const item = data[index];
return <div style={{ ...style }}>{item}</div>;
}, areEqual);
@andirkh
andirkh / selectors.template.js
Last active March 27, 2021 22:51
Template for testing selectors
import { fromJS } from 'immutable';
import {
...
} from '#src/containers/ContainersName/selectors';
import { initialState } from '#src/containers/ContainersName/reducer';
let mockReduxData;
jest.mock('reselect', () => ({
createSelector: (fn, fn2) => {
@andirkh
andirkh / container.template.js
Last active March 31, 2021 07:08
Minimum Viable Unit Test for React Container/Component
import React from 'react';
import { shallow } from 'enzyme';
import ContainerName from '#containers/ContainerName';
describe('<ContainerName />', () => {
let wrapper;
beforeEach(() => {
wrapper = shallow(<ContainerName />);
});
afterEach(() => {
@andirkh
andirkh / convert_stereo_mono.py
Created February 8, 2022 06:16
Convert Stereo to Mono
import os
from pydub import AudioSegment
DIRECTORY = './your_directory'
LIST_DIR = os.listdir(DIRECTORY)
for filename in sorted(LIST_DIR):
if filename.endswith('.wav'):
sound = AudioSegment.from_wav(DIRECTORY + "/" + filename)
sound = sound.set_channels(1)