Skip to content

Instantly share code, notes, and snippets.

View westmark's full-sized avatar

Fredrik Westmark westmark

View GitHub Profile
@westmark
westmark / restricted_python_test.py
Created February 21, 2012 13:51
Testing RestrictedPython
from RestrictedPython import compile_restricted
from RestrictedPython.PrintCollector import PrintCollector
from RestrictedPython.Guards import safe_builtins, full_write_guard
def getitem(obj, index):
if obj is not None and type(obj) in (list, tuple, dict):
return obj[index]
raise Exception()
new Ajax.Request(link.href, {
method:'POST',
onSuccess:function (transport) {
if (row !== null) {
row.highlight({duration:0.5});
}
window.location.reload();
},
onFailure:function (transport) {
alert("Ett fel intr\u00e4ffade. (HTTP-svarskod " + transport.status + ")");
@westmark
westmark / event.py
Created June 27, 2012 08:47
Dynamic Event Manager
class EventGroup(object):
def __init__(self):
self._sub_events = {}
self._listeners = set()
self._batched = False
self._batched_args = []
def __getitem__(self, name):
return self._sub_events.setdefault(name.lower(), EventGroup())
@westmark
westmark / wrap.js
Last active August 29, 2015 14:04
Object property wrapper
var Prototype = {
}
var Wrap = function () {
var mappedAttributes = {};
_.each(arguments, function (a) {
if (a && a.length) {
var i = 1
k = a.substring(0, i);
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to make opened Markdown files always be soft wrapped:
#
# path = require 'path'
#

Keybase proof

I hereby claim:

  • I am westmark on github.
  • I am westmark (https://keybase.io/westmark) on keybase.
  • I have a public key whose fingerprint is A1CC 0A4C A299 53AB 0EC1 B4A2 0E5D 6026 BDCE 971A

To claim this, I am signing this object:

@westmark
westmark / auth0-verify.js
Last active August 18, 2022 07:45
Auth0 JWT Verification
/**
The MIT License (MIT)
Copyright (c) 2017 Fredrik Westmark
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@westmark
westmark / Defaults
Created November 29, 2018 13:20
MacOS setup
defaults -currentHost write -globalDomain AppleFontSmoothing -int 2
defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO
defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool FALSE
defaults write com.apple.finder AppleShowAllFiles YES
[LicensingClient] ERROR Failed to connect to local IPC
[Licensing::Module] Failed to connect to channel: LicenseClient-fredrik
Launching external process: /Applications/2019.3.2f1/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/Resources/Unity.Licensing.Client
[Licensing::Module] Successfully launched the LicensingClient
[Licensing::Module] Successfully connected to LicensingClient on channel: LicenseClient-fredrik
[Licensing::Module] Successfully launched and connected to LicensingClient
Entitlement-based licensing initiated
[LicensingClient] Licenses Updated successfully in LicensingClient
[Licensing::Module] Serial number assigned to: "F4-4BQ8-26K2-3KAQ-RCKM-XXXX"\n[Package Manager] Server::Start -- Port 64161 was selected
Launching external process: /Applications/2019.3.2f1/Unity.app/Contents/Resources/PackageManager/Server/UnityPackageManager
@westmark
westmark / nx-generate-deps.ts
Created June 26, 2020 07:06
package.json generator for @nrwl:node apps
import * as fs from 'fs';
import { resolve } from 'path';
import { promisify } from 'util';
import yargs from 'yargs';
const exists = promisify(fs.exists);
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);
const root = resolve(__dirname, '..', '..');