Skip to content

Instantly share code, notes, and snippets.

@morajabi
morajabi / useRect.js
Created February 18, 2019 14:35
useRect — getBoundingClientRect() React Hook with resize handler
import { useLayoutEffect, useCallback, useState } from 'react'
export const useRect = (ref) => {
const [rect, setRect] = useState(getRect(ref ? ref.current : null))
const handleResize = useCallback(() => {
if (!ref.current) {
return
}
@FrankSpierings
FrankSpierings / README.md
Last active February 20, 2025 10:48
Linux Container Escapes and Hardening
@hex-ci
hex-ci / index.html
Last active January 9, 2020 01:18
基于 itchat 的微信机器人例子,支持浏览器登录机器人,支持机器人进程管理,支持热重启
<!DOCTYPE html>
<!-- 请把这个文件放到 templates 目录下 -->
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Wechat</title>
</head>
<body>
{% if alive %}
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.resize-drag{
z-index:200;
position:absolute;
border: 2px dashed #ccc;
}
.out-container-content ,.container-content{
@chrismdp
chrismdp / s3.sh
Last active January 23, 2025 09:26
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@importre
importre / AndroidManifest.xml
Created October 22, 2014 10:39
Toolbar Animation with Navigation Drawer
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sample.myapplication" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
@welbornprod
welbornprod / Embedded Python in BASH
Created August 14, 2014 23:22
A little trick to embed python code in a BASH script.
#!/bin/bash
# Here are some embedded Python examples using Python3.
# They are put into functions for separation and clarity.
# Simple usage, only using python to print the date.
# This is not really a good example, because the `date`
# command works just as well.
function date_time {
@joakimbeng
joakimbeng / router.html
Last active March 15, 2024 06:18
A really simple Javascript router
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Building a router</title>
<script>
// Put John's template engine code here...
(function () {
// A hash to store our routes: