Skip to content

Instantly share code, notes, and snippets.

@phstc
phstc / pageChangesNotifier.js
Created December 22, 2010 14:36
Use this Bookmarklet to start monitoring a page for changes. When a page change is detected you will receive an alert notifying the changes
javascript:(function(){
/*@author Pablo Cantero - http://pablocantero.com/blog/2010/09/15/javascript-para-notificar-se-o-site-teve-alteracoes*/
var xmlHttp = getXMLHttpObj();
if(xmlHttp == null){
alert('Failed to load XMLHTTP');
return;
}
var actual = getPageContent(xmlHttp, window.location.href);
var intervalId = window.setInterval(function(){
var current = getPageContent(xmlHttp, window.location.href);
<html>
<head>
<title>Test</title>
</head>
<script async>
/*
relay
usbProductId: 24577
usbVendorId: 1027
const { SerialPort } = require('serialport')
async function listSerialPorts() {
await SerialPort.list().then((ports, err) => {
if (err) {
// document.getElementById('error').textContent = err.message
console.error(err.message)
return
} else {
// document.getElementById('error').textContent = ''
@phstc
phstc / retool-ddb-cdk.ts
Last active February 20, 2023 16:51
Retool DDB integration + AWS CDK IAM User and Policy
// See https://docs.retool.com/docs/dynamodb-integration
import { Stack, StackProps } from "aws-cdk-lib";
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
import * as iam from "aws-cdk-lib/aws-iam";
import { Construct } from "constructs";
export class DataStack extends Stack {
public readonly table: dynamodb.Table;
constructor(scope: Construct, id: string, props?: StackProps) {
@phstc
phstc / create-users.ts
Last active May 3, 2021 04:06
aws-cdk script for provisioning users + s3 buckets
/*
For deploying it:
Install aws-cdk: https://github.com/awslabs/aws-cdk then
npm run build
cdk deploy
*/
import cdk = require('@aws-cdk/cdk')
@phstc
phstc / resize
Last active July 13, 2020 01:31
tell application "Google Chrome" to set the bounds of the front window to {1376, 0, 3440, 1440}
tell application "iTerm" to set the bounds of the front window to {1376, 0, 3440, 1440}
tell application "Slack" to set the bounds of the front window to {0, 0, 1376, 1440}
tell application "System Events" to tell application process "WhatsApp"
tell window 1
set {size, position} to {{1376, 1440}, {0, 0}}
end tell
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
# /usr/bin/notify-site-is-down.rb
require "rubygems"
require "twilio-ruby"
account_sid = ENV["TWILIO_ACCOUNT_SID"]
auth_token = ENV["TWILIO_AUTH_TOKEN"]
@client = Twilio::REST::Client.new account_sid, auth_token
@phstc
phstc / README.md
Last active September 15, 2019 18:38
K6 GitHub action

Run k6 for all branches prefixed with k6/, i.e. k6/my-test

@phstc
phstc / happy_oop.rb
Created October 26, 2010 22:39
Happy OOP examples using Ruby
#These Ruby OOP examples, are based on the Rails 3 presentation by @guilhermecaelum
class Person
#the attribute name is immutable
def initialize(name)
@name = name
end
def name
@name
end
end