Skip to content

Instantly share code, notes, and snippets.

@phparkle
phparkle / .tmux.conf
Created October 27, 2020 10:33
dotfiles
set -g default-terminal "screen-256color"
@phparkle
phparkle / fg-events-manager-hack.php
Created July 15, 2020 09:07
FG Events Manager Hack
<?php
/*
Plugin Name: FG Events Manager Hack
Plugin URI:
Description: Modifies the behaviour of Events Manager plugin
Add the start event date in the permalink using the format /YYYY/mm/dd
Author: Frédéric GILLES
Version: 1.0
*/
@phparkle
phparkle / .htaccess
Last active July 8, 2020 04:41
Parkle's Cheat Sheet
# HTTP Basic Auth
# Run `htpasswd -c .htpasswd user` to generate .htpasswd file
AuthType Basic
AuthName "Authentication Required"
AuthUserFile /absolute/path/to/.htpasswd
Require valid-user
# Exclude the file upload and WP CRON scripts from authentication
<FilesMatch "(async-upload\.php|wp-cron\.php|xmlrpc\.php)$">
Satisfy Any
@phparkle
phparkle / wp.sh
Last active August 10, 2020 22:32 — forked from phlbnks/wp.sh
#!/bin/bash -e
clear
echo "============================================"
echo "WordPress Install Script"
echo "============================================"
echo "Do you need to setup new MySQL database? (y/n)"
read -e setupmysql
if [ "$setupmysql" == y ] ; then
echo "MySQL Admin User: "
read -e mysqluser
int len1 = s1.length();
int len2 = s2.length();
int lim = Math.min(len1, len2);
for (int k = 0; k < lim; ++k) {
char c1 = s1.charAt(len1 - 1 - k);
char c2 = s2.charAt(len2 - 1 - k);
if (c1 != c2)
return c1 - c2;
}
public class UpperBound {
public static int upperBound(String[] words, int lo, int hi, String word) {
while (lo < hi) {
int mid = lo + (hi - lo >> 1);
String other = words[mid];
int toffset = word.length() - 2;
int ooffset = other.length() - 2;
if (word.regionMatches(toffset, other, ooffset, 2))
lo = mid + 1;
@phparkle
phparkle / main.cpp
Created October 13, 2017 15:48
compareDoubleEqual Test
#include <limits>
#include <iostream>
using namespace std;
// The double comparison function, exactly as provided in the tutorial
bool compareDoubleEqual(double val1, double val2) {
if(abs(val1 - val2)<2.0*std::numeric_limits<double>::epsilon())
return true;
else
public static void main(String[] args) {
In in = new In(args[0]);
int n = in.readInt();
int[][] blocks = new int[n][n];
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
blocks[i][j] = in.readInt();
Board initial = new Board(blocks);
Solver solver = new Solver(initial);
if (solver.isSolvable()) {
// Hi! I'm going to show you how to write a Java program that outputs the sum
// of two given numbers. I will assume that this is your first time programming
// and try to explain as much as possible.
// Before we get started, any text that follows two consecutive backslashes is
// called a "comment". You are reading a comment right now. Comments are for
// documenting code and will be completely ignored by the computer.
// Ok, let's get into it. In order to read values from input, we must import
// Scanner: