Skip to content

Instantly share code, notes, and snippets.

@cassus
cassus / GoogleScript.js
Last active March 12, 2024 08:27
Automatically add/remove guests on Google Calendar Events
// Create a trigger on this
function onCalendarChange(triggerEvent) {
Logger.log("triggerEvent:", triggerEvent);
Main()
}
function Main() {
var today = new Date();
var endDate = new Date();
@cassus
cassus / i18n-ts-with-namespaces.ts
Created October 7, 2023 07:52
i18n-ts-with-namespaces.ts
import type { Paths, I18n, Translate } from "next-translate"
type Tail<T> = T extends [unknown, ...infer Rest] ? Rest : never
export type TranslationsKeys = {
common: Paths<typeof import("./locales/en/common.json")>
["feat-analytics"]: Paths<typeof import("./locales/en/feat-analytics.json")>
["feat-participate"]: Paths<
typeof import("./locales/en/feat-participate.json")
>
@cassus
cassus / Dev platform settings
Created November 1, 2016 14:54
Zapier app to read Activity and Sleep data from FitBit
## Triggers (Bringing data into Zapier)
### Sleep - polling
https://api.fitbit.com/1/user/-/sleep/date/today.json
### Activity - polling
https://api.fitbit.com/1/user/-/activities/list.json?beforeDate=today&sort=desc&limit=10&offset=0
## Scripting API
see script.js
@cassus
cassus / Delay.js
Created October 25, 2014 12:24
Delay component for Facebook React
/** @jsx React.DOM */
module React from 'react'
var Delay = React.createClass({
propTypes: {
by: React.PropTypes.number.isRequired,
},
getInitialState() {
@cassus
cassus / DisplayModal.js
Created August 10, 2014 11:43
Open a react-bootstrap.Modal from a react-router Route
/** @jsx React.DOM */
/** @type React */
module React from 'react'
var RB = require('react-bootstrap')
module Router from 'react-router'
var DisplayModal = React.createClass({
mixins: [RB.OverlayMixin],
@cassus
cassus / admin.py
Last active August 29, 2015 13:57
Action button on django model edit page
class MyAdmin(admin.ModelAdmin):
def response_change(self, request, obj):
if "_activate_and_send_email" in request.POST:
self.activate_account_and_send_email(request, (obj,))
return HttpResponseRedirect(request.path)
return super().response_change(request, obj)
@cassus
cassus / admin.py
Last active July 23, 2024 04:43
Django admin action as row button
class MyAdmin(admin.ModelAdmin):
list_display = (..., 'actions_html')
def actions_html(self, obj):
return format_html('<button class="btn" type="button" onclick="activate_and_send_email({pk})">Activate and send email</button>', pk=obj.pk)
actions_html.allow_tags = True
actions_html.short_description = "Actions"
@cassus
cassus / load_history_to_sonar.py
Created August 14, 2013 10:42
Load repo history to sonar
#!/usr/bin/env python
from datetime import datetime
import os
import sys
from dateutil.relativedelta import relativedelta
import sh
def checkout_repo_at(path, dt):