// default exports
export default 42;
export default {};
export default [];
export default (1 + 2);
export default foo;
export default function () {}
export default class {}
export default function foo () {}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const crypto = require('crypto'); | |
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters) | |
const IV_LENGTH = 16; // For AES, this is always 16 | |
function encrypt(text) { | |
let iv = crypto.randomBytes(IV_LENGTH); | |
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use Python 3 for easy unicode | |
$ virtualenv -p python3 .env | |
$ source .env/bin/activate | |
$ pip install django | |
$ deactivate | |
# Start new django project and app | |
$ django-admin.py startproject mysite | |
$ ./manage.py migrate | |
$ ./manage.py createsuperuser |
It's hard to find a good example of how to verify SAML signatures online. There are plenty magic that "just calls a Java method" -- but few clear step-by-step guide.
This gist covers the signature check of a SAML response in Ruby, and as such it's also an example of how to verify an XML Secure.
The code here is lifted entirely from Morten Primdahls and Zendesks awesome SAMLR library.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Ember Data: Dependent Relationships | |
This package extends Ember Data to support creating relationships | |
where a model's dirty state depends not only on its own attributes | |
but on the dirty state of models in dependent relationships as well. | |
```javascript | |
App.Thing = DS.Model.extend({ | |
name : DS.attr('string'), |
Routes file (routes.rb
):
resources :data_loaders do
collection do
delete 'multiple_destroy'
end
end
The controller:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Calendar" | |
-- delete everything from the destination calendar | |
-- TODO: Change "Destination Calendar" to be the name of your destination calendar | |
repeat with anEvent in (get events of calendar "Destination Calendar") | |
delete anEvent | |
end repeat | |
-- copy all events from the source calendar to the destination | |
-- TODO: Change "Source Calendar" to be the name of your source calendar | |
-- TODO: Change "Destination Calendar" to be the name of your destination calendar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
<!-- TODO: ${1:message} --> | |
]]></content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
<tabTrigger>to</tabTrigger> | |
<!-- Optional: Set a scope to limit where the snippet will trigger --> | |
<!-- <scope>source.python</scope> --> | |
</snippet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
if ARGV.size.zero? | |
puts %Q[ | |
Usage: | |
./to_csv.rb file.yml > out.csv | |
] | |
exit | |
end |
NewerOlder