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
from django.http import HttpResponsePermanentRedirect | |
class SecureRequestPropagationMiddleware(object): | |
""" | |
When running on AWS Elastic Beanstalk, we suffer | |
an issue where HTTPS requests arriving at the load | |
balancer are propagated to the individual hosts as | |
HTTP requests. If the host issues a redirect it | |
issues it using the same scheme as its incoming |
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
from django.utils.translation import ugettext_lazy as _ | |
class MyUserAdmin(UserAdmin): | |
# The forms to add and change user instances | |
form = UserChangeForm | |
add_form = UserCreationForm | |
# The fields to be used in displaying the User model. | |
# These override the definitions on the base UserAdmin | |
# that reference specific fields on auth.User. |
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
# Filename : if.py | |
number = 23 | |
guess = int(raw_input('Enter an integer : ')) | |
if guess == number: | |
print "Congratulations, you guessed it." # New block starts here | |
print "(but you do not win any prizes!)" # New block ends here | |
elif guess < number: | |
print "No, it is a little higher than that" # Another block | |
# You can do whatever you want in a block ... | |
else: |
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
$(window).keydown(function (event) { | |
if (event.keyCode == 13) { | |
event.preventDefault(); | |
return false; | |
} | |
}); |
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
# FOR PARTNER DEVELOPERS | |
# You will need to have your certificates installed for any partner-specific calls to work. | |
# The cert simply needs to be accessible by this code and its abosolute path added to lines 20 & 21 below. | |
# For administrative actions, like creating accounts and transferring credits, you should not use impersonate_user when calling login. | |
# Rather, impersonate_user should only be called when making calls on behalf of a subaccount: creating emails, lists, getting reporting, etc. | |
# | |
# FOR EVERYONE | |
# This code will take you through creating a list and campaign, associating the two, and launching the campaign. | |
# There are several sections that you can update, including the email address we send the email to and the HTML content. | |
# The only section you MUST update is the username and password below. |
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
On multi-core/thread systems libf77blas.so, libstcblas.so and | |
liblapack.so.3.4.1 are single-threaded, libptcblas.so, libptf77blas.so | |
and libptlapack.so.3.4.1 are multi-threaded. By default | |
libcblas.so, libblas.so and liblapack.so point to the multi-threaded | |
versions. | |
The default can be changed by making libcblas.so, libblas.so and | |
liblapack.so.3 point to the single threaded libraries, i.e. | |
ln -sf libf77blas.so libblas.so; ln -sf libstcblas.so libcblas.so; | |
ln -sf liblapack.so.3.4.1 liblapack.so.3 |
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
import signal | |
class TimeoutError(Exception): | |
pass | |
def timeout_handler(signum, frame): | |
raise TimeoutError('Fuck you time') |
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
<?php | |
/** | |
* Example of simple product POST using Admin account via Magento REST API. OAuth authorization is used | |
*/ | |
$callbackUrl = "http://magento-site.com/oauth_admin.php"; | |
$temporaryCredentialsRequestUrl = "http://magento-site.com/oauth/initiate?oauth_callback=" . urlencode($callbackUrl); | |
$adminAuthorizationUrl = 'http://magento-site.com/admin/oauth_authorize'; | |
$accessTokenRequestUrl = 'http://magento-site.com/oauth/token'; | |
$apiUrl = 'http://magento-site.com/api/rest'; | |
$consumerKey = '<CONSUMER_KEY>'; |
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
BEGIN; | |
CREATE TABLE `filer_folder` ( | |
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, | |
`parent_id` integer, | |
`name` varchar(255) NOT NULL, | |
`owner_id` integer, | |
`uploaded_at` datetime NOT NULL, | |
`created_at` datetime NOT NULL, | |
`modified_at` datetime NOT NULL, | |
`lft` integer UNSIGNED NOT NULL, |
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
BEGIN; | |
CREATE TABLE `form_designer_formdefinition` ( | |
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, | |
`name` varchar(255) NOT NULL UNIQUE, | |
`require_hash` bool NOT NULL, | |
`private_hash` varchar(40) NOT NULL, | |
`public_hash` varchar(40) NOT NULL, | |
`title` varchar(255), | |
`body` longtext, | |
`action` varchar(255), |