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
#python script for fibonacci between 1 and 100 | |
#example: 1,2,3,5,8,13 | |
hold=[] | |
temp1 = 1 | |
temp2 = 2 | |
hold.append(temp1); hold.append(temp2) | |
for i in range(3, 101): | |
temp3 = temp1 + temp2 |
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
1. open a browser and go to https://goo.gl/fd3zc, that will download crouton | |
2. hit Ctrl+alt+T and then type shell and press enter | |
$ shell | |
3. install ubuntu via | |
$ sudo sh ~/Downloads/crouton -r trusty -t xfce | |
#that will install ubuntu 14.04 with xfce desktop environment | |
4. to list available versions: |
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
INFO global: Vagrant version: 1.7.1 | |
INFO global: Ruby version: 2.0.0 | |
INFO global: RubyGems version: 2.0.14 | |
INFO global: VAGRANT_EXECUTABLE="/opt/vagrant/bin/../embedded/gems/gems/vagrant-1.7.1/bin/vagrant" | |
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="/opt/vagrant/bin/../embedded" | |
INFO global: VAGRANT_INSTALLER_VERSION="2" | |
INFO global: VAGRANT_DETECTED_OS="Linux" | |
INFO global: VAGRANT_INSTALLER_ENV="1" | |
INFO global: VAGRANT_INTERNAL_BUNDLERIZED="1" | |
INFO global: VAGRANT_LOG="debug" |
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
name: execute bash script | |
command: bash {{ APP_DIR }}/some_script.sh |
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 os | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") | |
# This application object is used by the development server | |
# as well as any WSGI server configured to use this file. | |
import django.core.handlers.wsgi | |
application = django.core.handlers.wsgi.WSGIHandler() |
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
#Taken from: | |
http://nategood.com/client-side-certificate-authentication-in-ngi | |
#reposted here to preserve history | |
#see: https://gist.github.com/komuW/076231fd9b10bb73e40f for a bash script to auto-generate all this | |
Client Side Certificate Auth in Nginx | |
Why Client-Side Certificate Authentication? Why nginx? | |
I sometimes peruse the ReST questions of stackoverflow.com. Many times I see questions about authentication. There are many options (Basic HTTP Auth, Digest HTTP Auth, OAuth, OAuth Wrap, etc.) however when security is of importance, I like to recommend client side certificates. This is the route our team at ShowClix chose when implementing our API. |
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
class DateTimefaker(datetime): | |
""" | |
fake datetime to use your own custom datetimes | |
""" | |
def __new__(cls, *args, **kwargs): | |
return datetime.__new__(datetime, *args, **kwargs) | |
class TestSomething(TestCase): | |
fixtures = ['test_data'] |
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
# We compare/measure reading a file from memory(1) vs reading from filesytem(2) | |
################################## | |
### 1. reading file from memory ## | |
################################## | |
import time | |
import mmap | |
filename = "myfile.txt" |
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 rest_framework.test import APIClient | |
class SomeTests(LiveServerTestCase): | |
def setUp(self): | |
self.real_URL = settings.SOME_URL | |
settings.SOME_URL = '{0}/some-url/'.format(self.live_server_url) | |
self.client = APIClient() | |
self.payload = """<some>xml-string</xml>""" |
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
package main | |
import ( | |
"fmt" | |
"net/http" | |
) | |
type Mystring string | |
type Mystruct struct { |
OlderNewer