Skip to content

Instantly share code, notes, and snippets.

View fm's full-sized avatar

Faisal Misle fm

View GitHub Profile
@JimWestergren
JimWestergren / checkPawnedPasswords.php
Last active December 22, 2023 23:06
Simple method to check the Pwned Passwords API using PHP
<?php
/**
* Simple method to use the API from https://www.troyhunt.com/ive-just-launched-pwned-passwords-version-2/
* Written by Jim Westergren and released to public domain
* @return int count
*/
function checkPawnedPasswords(string $password) : int
{
$sha1 = strtoupper(sha1($password));
$data = file_get_contents('https://api.pwnedpasswords.com/range/'.substr($sha1, 0, 5));
@ravibhure
ravibhure / git_rebase.md
Last active April 3, 2024 08:38
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream

@harrisonweinerman
harrisonweinerman / Harrison Weinerman
Last active August 29, 2015 14:21
Swift Riemann Sum Calculator
//This code works fine in a Swift playground.
let startingX = 0.0
let finishingX = 2.0
//make this smaller for more accuracy but slower calculation times
let increment = 0.1
var area = 0.0
func fOfX(x : Double) -> Double{
@ScottSmith95
ScottSmith95 / customuploads.php
Created February 16, 2014 05:52
A script for custom image uploads via Tweetbot or any other app that uses a similar format. Creates short file names for uploaded items that are essentially unique by using the time and date uploaded (see line 22, 23). Adapted from http://www.macstories.net/news/tweetbot-for-mac-review/#customuploads.
<?php
$domain = "img.scottshar.es/";
//server-side directory
$directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);
$uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] . $directory_self;
// Image filetype check source:
// http://designshack.net/articles/php-articles/smart-file-type-detection-using-php/
$tempFile = $_FILES['media']['tmp_name'];