Skip to content

Instantly share code, notes, and snippets.

View kevinyan815's full-sized avatar

Kevin Yan kevinyan815

View GitHub Profile
@pavlepredic
pavlepredic / gist:6220041
Created August 13, 2013 10:53
TimeInterval class
<?php
/**
* Representation of a time interval, such as 1 year,
* or a more complex interval such as 1 month, 4 days and 6 hours.
* Provides methods for adding and substracting this interval
* to/from a given DateTime object or to/from a UNIX timestamp.
* Sample usage:
* $int = new TimeInterval(1, TimeInterval::YEAR); //1 year
* $int->addInterval(1, TimeInterval::MONTH); //allows creating more complex intervals (optional)
* $future = $int->addToDate(); //$future will be a DateTime object set to 1 year and 1 month from now
@jgrossi
jgrossi / Math.php
Created November 11, 2014 22:18
Math class from Taylor Otwell. Thanks to @brad (captain_jim1@yahoo.com) for the class content.
<?php
class Math {
/**
* The base.
*
* @var string
*/
private static $base = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
@andyshinn
andyshinn / composer.json
Last active February 18, 2024 12:05
Docker Compose PHP Composer Example
{
"require": {
"mfacenet/hello-world": "v1.*"
}
}
@nielsutrecht
nielsutrecht / RsaExample.java
Created December 28, 2016 14:13
Example of RSA generation, sign, verify, encryption, decryption and keystores in Java
import javax.crypto.Cipher;
import java.io.InputStream;
import java.security.*;
import java.util.Base64;
import static java.nio.charset.StandardCharsets.UTF_8;
public class RsaExample {
public static KeyPair generateKeyPair() throws Exception {
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
// Package events provides an event dispatcher for registering callbacks
// with specific events and handling them when they occur.
package events
import (
"reflect"
"sync"
)
// Sample Event Types
@MelchiSalins
MelchiSalins / http-rate-limit.go
Last active June 9, 2024 18:12
GoLang HTTP Client with Rate Limiting
package main
import (
"context"
"fmt"
"net/http"
"time"
"golang.org/x/time/rate"
)