Skip to content

Instantly share code, notes, and snippets.

View drizzentic's full-sized avatar

Drizzentic drizzentic

View GitHub Profile
@drizzentic
drizzentic / Howto.md
Created May 5, 2021 15:59 — forked from brentjanderson/Howto.md
SSH Tunneling with Firefox

Sometimes it is useful to route traffic through a different machine for testing or development. At work, we have a VPN to a remote facility that we haven't bothered to fix for routing, so the only way to access a certain machine over that VPN is via an SSH tunnel to a machine that is reachable over the VPN. Other times, I have used this technique to test internet-facing requests against sites I am developing. It is pretty easy, and if you don't use firefox regularly, you can treat Firefox as your "Proxy" browser and other browsers can use a normal configuration (Although you can also configure an entire system to use the proxy, other articles exists that discuss this potential).

  1. Open a terminal
@drizzentic
drizzentic / group-objects-by-property.md
Created July 1, 2019 11:54 — forked from JamieMason/group-objects-by-property.md
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
<source ip> <destination ip> : <secrettype> <secret>
left right: PSK 1245
# ipsec.conf
conn aws-to-gcp
keyexchange=ikev1
authby=secret
type=tunnel
left=172.xx.xx.4 #Host internal ip address
leftid=aw
leftsubnet=172.xx.0.0/16 #Host externa ip/Encryption domain
right=35.xxx.xxx.28 #Peer2 ip address
rightid=gcp
# ipsec.conf
conn gcp-to-aws
keyexchange=ikev1
authby=secret
type=tunnel
left=10.xxx.0.4 #Host internal ip address
leftid=gcp
leftsubnet=10.xxx.0.0/9 #Host intranet
right=xx.xx.xx.xx #Peer2 ip address
rightid=aws
@drizzentic
drizzentic / Mfactor.java
Last active September 5, 2016 14:01
M-Factor Authentication
import java.util.*;
import java.security.*;
import java.lang.*;
class Rand{
//We generate a pattern to be used by the client applications
//We make an assumption that the application uses a four digita pin and thus we give it an initial value of 1234
//intialize the original password
final static String originalPassword="8217";
static String enteredPassword;
@drizzentic
drizzentic / index.php
Created July 19, 2016 14:20
Sample USSD Application
<!-- MIT License
Copyright (c) 2016 Derrick Rono
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@drizzentic
drizzentic / gist:38f1889e40c9460e6e2187f20b0abe8c
Created May 11, 2016 08:15 — forked from nghuuphuoc/gist:8282411
Install wkhtmltopdf on Centos 6 x64
$ wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2
$ tar xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2
$ mv wkhtmltopdf-amd64 /usr/bin/wkhtmltopdf
// In case you got the issue
// wkhtmltopdf: error while loading shared libraries:
// libfontconfig.so.1: cannot open shared object file: No such file or directory
//
// run the command below:
$ yum install urw-fonts libXext libXrender fontconfig libfontconfig.so.1
package main
import (
"bufio"
"encoding/csv"
"encoding/json"
"fmt"
"io"
"os"
"path/filepath"
<?php
class LoginAttempt extends ActiveRecord
{
const LOGIN_ATTEMPT_LIMIT = 5; // ログイン試行回数のリミット
const BANNED_IP_EXPIRATION_TIME = '+1 hour'; // この場合は禁止されてから一時間経たないとログインできない
...
/**
* @see CActiveRecord::beforeSave()
*/