Skip to content

Instantly share code, notes, and snippets.

View yannisalexiou's full-sized avatar
🎯
Focusing

Yannis Alexiou yannisalexiou

🎯
Focusing
View GitHub Profile
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@MaherSaif
MaherSaif / hook.js
Created April 22, 2012 12:49
simple javascript hooks system
Expected Result:
----------------
One
Two
Three
Four
Six
@IanVaughan
IanVaughan / README.md
Created June 7, 2012 09:57
Push branch from one remote into another

Push branch from one remote into another

Add remote2 as a remote

$ git remote -v
remote2 git@github.com:repo2.git (fetch)
remote2 git@github.com:repo2.git (push)
origin  git@github.com:repo.git (fetch)
origin  git@github.com:repo.git (push)

Hacking the SamKnows Whitebox

The SamKnows Whitebox is a free router (TP-Link TL-WDR3600) provided by SamKnows to gather internet speed statistics. Ok that's great, but any person with a small amount of hacker's spirit will want to hack it to install some custom firmware to take advantage of the two gigantic antennas on the back, the USB ports and everything else.

Step 1 : Debug mode

Root access can be obtained via a "debug mode" on the router giving you a direct root shell via telnet, amazingly simple.

  • Disconnect the Whitebox from the internet.
  • Connect your computer directly to the Whitebox via Ethernet to one of the four ethernet ports on the Whitebox.
  • Configure your computer's IP settings to "Manual" setting the computer's IP address to 192.168.1.2, the Subnet Mask to 255.255.255.0 and the Gateway to 192.168.1.1.
  • Turn off the Whitebox.
@codeBelt
codeBelt / Select Handlebar Block helper.js
Last active May 29, 2024 09:19
Select & Multi Select Handlebar Block Helper
/**
* Sets the 'selected' property on the select option(s) when the value is passed in.
*
* @method selectHelper
* @example
* // selectValue = "69"
* // selectValue = "69,70,71"
* <select>
* {{#selectHelper selectValue}}
@bsara
bsara / js.gitignore
Last active October 31, 2023 03:39
.gitignore File for JavaScript Projects
#---------------------------------------#
# Project Ignores #
#---------------------------------------#
# output
/.temp
/.tmp
/build
/dist
@ChrisLowe-Takor
ChrisLowe-Takor / ClosureAsRxObservable.swift
Last active November 21, 2021 01:53
Creating an RxSwift Observable from a closure
// Say we have an Alamofire request we want to consume as an Observable..
func fooAsObservable(URL: String, headers: [String: AnyObject?]) -> Observable<Foo> {
return create { observer in
let request = Alamofire(.GET, URL, headers: headers
.responseJSON(completionHandler: { (_, _, result) in
switch result {
@joepie91
joepie91 / random.md
Last active July 13, 2024 16:15
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@rsaenzi
rsaenzi / UIViewController+Load.swift
Last active October 19, 2021 13:05
To load a UIViewController by the class name, avoiding ! operator and using a string literal for the name of the viewController identifier
//
// UIViewController+Load.swift
//
// Created by Rigoberto Sáenz Imbacuán (https://www.linkedin.com/in/rsaenzi/)
// Copyright © 2019. All rights reserved.
//
import UIKit
extension UIViewController {
/// Every view interacting with a `SayHelloViewModel` instance can conform to this.
protocol SayHelloViewModelBindable {
var disposeBag: DisposeBag? { get }
func bind(to viewModel: SayHelloViewModel)
}
/// TableViewCells
final class TextFieldCell: UITableViewCell, SayHelloViewModelBindable {
@IBOutlet weak var nameTextField: UITextField!
var disposeBag: DisposeBag?