Skip to content

Instantly share code, notes, and snippets.

View ishowshao's full-sized avatar

ishowshao ishowshao

  • unemployed
  • Shanghai, China
View GitHub Profile
@turret-io
turret-io / aes_enc_dec.php
Last active June 5, 2024 21:34
AES encryption/decryption in PHP
<?php
// DEFINE our cipher
define('AES_256_CBC', 'aes-256-cbc');
// Generate a 256-bit encryption key
// This should be stored somewhere instead of recreating it each time
$encryption_key = openssl_random_pseudo_bytes(32);
// Generate an initialization vector
// This *MUST* be available for decryption as well
@hal0gen
hal0gen / _mobile-ready-web-app.html
Last active July 13, 2024 18:52 — forked from tfausak/ios-8-web-app.html
iOS + Android settings for web applications
<!doctype html>
<!-- Adapted from https://gist.github.com/tfausak/2222823 -->
<html>
<head>
<title>Mobile-ready web app</title>
<!-- CONFIGURATION -->
/*
* Copyright (c) 2010 Apple Inc. All rights reserved.
*/
function characterNeedsScoreMultiplier(e) {
if (!e || e.length === 0)
return !1;
var t = e.charCodeAt(0);
return t > 11904 && t < 12031?!0 : t > 12352 && t < 12543?!0 : t > 12736 && t < 19903?!0 : t > 19968 && t < 40959?!0 : t > 44032 && t < 55215?!0 : t > 63744 && t < 64255?!0 : t > 65072 && t < 65103?!0 : t > 131072 && t < 173791?!0 : t > 194560 && t < 195103?!0 : !1
}
function domDistance(e, t, n) {
@mdonkers
mdonkers / server.py
Last active June 25, 2024 18:48
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
License: MIT License
Copyright (c) 2023 Miel Donkers
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
@kinlane
kinlane / long-running-curl-sse.php
Created February 15, 2018 17:38
Long Running PHP CURL Requests To Handle Server Sent Events (SSE)
<?php
// prepare headers for API call
$request_headers = array();
// prepare the url of the api I am calling
$api_url = "http://api.example.com?parameters=whatever";
// append streamdata sandbox proxy
$url = 'https://streamdata.motwin.net/' . $api_url;
@flymrc
flymrc / aes-cbc-padding.kts
Last active October 30, 2023 13:24
Kotlin AES Encryption and Decryption
// ref: https://www.baeldung.com/java-aes-encryption-decryption
import java.util.*
import javax.crypto.Cipher
import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec
fun decrypt(algorithm: String, cipherText: String, key: SecretKeySpec, iv: IvParameterSpec): String {
val cipher = Cipher.getInstance(algorithm)
val options = listOf("Bengaluru", "Delhi", "Bombay", "Calcutta")
var expanded by remember { mutableStateOf(false) }
var selectedOptionText by remember { mutableStateOf(options[0]) }
ExposedDropdownMenuBox(
modifier = Modifier.padding(
start = 32.dp,
end = 32.dp
),
expanded = expanded,