Skip to content

Instantly share code, notes, and snippets.

View linus-amg's full-sized avatar

Linus Gubenis linus-amg

  • Mexico, Berlin
  • 08:51 (UTC -06:00)
View GitHub Profile
@linus-amg
linus-amg / truncate.sql
Created January 12, 2023 18:13
⚠️ this sql query truncates all tables in the current schema (only tested in postgres) ⚠️
// this is dangerous, use with care, it truncates all tables in the current schema
DO $$ DECLARE
r RECORD;
BEGIN
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP
EXECUTE 'TRUNCATE TABLE ' || quote_ident(r.tablename) || ' CASCADE';
END LOOP;
END $$;
@linus-amg
linus-amg / gist:e6f71705c53becc85a27224d3ee00210
Created August 9, 2019 13:46
some helpful regex for refactoring stores
(this\.props.)[A-Za-z]+(Store)
(this\.props.)[A-Za-z]+(Service)
(Store).{0,}=.{0,}(this\.props)
@linus-amg
linus-amg / UIStore.js
Created April 27, 2018 11:32
UIStore
import { action, observable } from 'mobx';
const DEFAULT_STATE = {
counter: 0,
};
class UIStore {
@observable state;
constructor(initialState = DEFAULT_STATE) {
@linus-amg
linus-amg / bla.js
Last active November 28, 2017 11:42
const StyledModeler = styled(Modeler)`
.djs-palette {
${({ loadingModeler }) => loadingModeler && `display: none`};
}
`;
@linus-amg
linus-amg / cloudSettings
Last active October 17, 2021 19:23
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-10-17T19:23:18.513Z","extensionVersion":"v3.4.3"}
@linus-amg
linus-amg / README.md
Created January 19, 2017 02:18 — forked from rcknr/README.md
Using Let's Encrypt certificates with Amazon API Gateway

##Using Let's Encrypt certificates with AWS API Gateway

Before starting off with API Gateway set up it's worth mentioning that certificate configuration for this particular service is so far isn't well integrated, therefore different from other AWS services. Despite it using CloudFrount to serve on custom domains it won't let you customize distributions it creates, however all the limitations of CloudFront naturally apply to API Gateway. The most important in this case is the size of the key, which is limited by 2048 bit. Many tutorials provide ready to use terminal commands that have the key size preset at 4096 bit for the sake of better security. This won't work with API Gateway and you'll get an error message about certificate's validity or incorrect chain which won't suggest you the real cause of the issue. Another consideration is that to add a custom domain to API Gateway you have to have a certif

@linus-amg
linus-amg / serverless.yml
Created January 17, 2017 20:24
serverless yml restApi howto?
accounts:
handler: handler.accounts
events:
- http:
handler: setup
method: POST
path: account/setup
integration: lambda
cors: true
- http:
const w = window;
w.Model = Backbone.Model;
w.Collection = Backbone.Collection;
w.Router = Backbone.Router;
w.ItemView = Marionette.ItemView;
w.LayoutView = Marionette.LayoutView;
w.CollectionView = Marionette.CollectionView;
w.CompositeView = Marionette.CompositeView;
w.AppRouter = Marionette.AppRouter;
# Thanks to this post:
# http://blog.ikato.com/post/15675823000/how-to-install-consolas-font-on-mac-os-x
$ brew install cabextract
$ cd ~/Downloads
$ mkdir consolas
$ cd consolas
$ curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe
$ cabextract PowerPointViewer.exe
$ cabextract ppviewer.cab
@linus-amg
linus-amg / ref.js
Created November 5, 2015 19:03
ref
function ref(obj, str) {
str = str.split(".");
for (var i = 0; i < str.length; i++)
obj = obj[str[i]];
return obj;
}
var obj = { a: { b: 1, c : { d : 3, e : 4}, f: 5 } }
str = 'a.c.d'
ref(obj, str) // 3