Skip to content

Instantly share code, notes, and snippets.

View rap2hpoutre's full-sized avatar

Raphaël Huchet rap2hpoutre

View GitHub Profile
@calebporzio
calebporzio / timer_helpers.php
Last active August 18, 2019 00:07
A simple helper function and macro for timing php scripts and eloquent queries
<?php
// Helper function.
if (! function_exists('timer')) {
function timer($expression)
{
$start = microtime(true);
if ($expression instanceof Closure) {
$expression();
@retep998
retep998 / Guide.md
Last active December 26, 2020 03:50

Installing OpenSSL for Rust on Windows with MSVC

When using MSVC Rust on Windows, everything typically works out of the box, up until you decide to do some web stuff with hyper. Suddenly a new dependency, openssl, is failing to build and you have no idea how to fix it. Fortunately this guide is here to save you!

WARNING: OpenSSL 1.1 support was only added in openssl-sys = "0.9". Older versions only support up to OpenSSL 1.0.2. sfackler/rust-openssl#452

  1. First you will need to download and install OpenSSL itself. You can download an installer from http://slproweb.com/products/Win32OpenSSL.html. In particular you want the newest version and not the light version. Make sure it matches the version of Rust you have, if you're using x86_64-pc-windows-msvc you will want Win64, and if you're using i9686-pc-windows-msvc you will want Win32. For the purpose of example I have installed Win64 OpenSSL v1.0.2h.
  2. If all went well you should now have OpenSSL installed somewh
@chuckplantain
chuckplantain / executionOrderJestJasmine.js
Created April 5, 2018 13:59
Execution order of async Jest/Jasmine test code
/**
* Demonstrate execution order of code in Jest/Jasmine
*/
function resolveAfter2Seconds(message) {
return new Promise((resolve) => {
setTimeout(() => {
resolve(message)
}, Math.ceil(Math.random() * 5000))
})
@TheDeveloper
TheDeveloper / http-aws-es.es6.js
Last active March 31, 2021 09:27
Use the Node elasticsearch client with Amazon ES
/**
* A Connection handler for Amazon ES.
*
* Uses the aws-sdk to make signed requests to an Amazon ES endpoint.
* Define the Amazon ES config and the connection handler
* in the client configuration:
*
* var es = require('elasticsearch').Client({
* hosts: 'https://amazon-es-host.us-east-1.es.amazonaws.com',
* connectionClass: require('http-aws-es'),
@hacfi
hacfi / disable-xdebug.sh
Created February 5, 2016 00:53
OS X homebrew php 7.0 enable/disable xdebug extension script
#!/bin/sh
sed -i.default "s/^zend_extension=/;zend_extension=/" /usr/local/etc/php/7.0/conf.d/ext-xdebug.ini
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.php70.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php70.plist
echo "xdebug disabled"
@magicznyleszek
magicznyleszek / random-non-overlapping-position.js
Last active April 11, 2022 21:37
JavaScript -- get random non-overlapping position
// declarations
var positions = [];
// Returns a random integer between min (included) and max (excluded)
// Using Math.round() will give you a non-uniform distribution!
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
// generate random positions
@avafloww
avafloww / PhpJava.java
Last active October 16, 2022 18:50
This snippet of code is syntactically valid in both PHP and Java, and produces the same output in both.
/*<?php
//*/public class PhpJava { public static void main(String[] args) { System.out.printf("/*%s",
//\u000A\u002F\u002A
class PhpJava {
static function main() {
echo(//\u000A\u002A\u002F
"Hello World!");
}}
//\u000A\u002F\u002A
PhpJava::main();
@jrmuizel
jrmuizel / PopularCrates.md
Created April 21, 2017 19:59
Popular crates
@FLamparski
FLamparski / index.html
Created September 4, 2014 20:13
Reactivity in vanilla JS? Yes you can!
<!DOCTYPE html>
<html>
<head>
<title>Object.observe</title>
</head>
<body>
<h1 reactive>Title here</h1>
<p reactive>Text here</p>
<hr />
<p><b>Hey!</b> Open up the console and change the <tt>title</tt>