Skip to content

Instantly share code, notes, and snippets.

View amelieykw's full-sized avatar

amelieykw amelieykw

  • Sophia Antipolis, France
View GitHub Profile
@amelieykw
amelieykw / Lecture 1: What is Computation?.md
Last active August 15, 2018 10:08
[MIT Courses » Introduction to Computer Science and Programming in Python] #MIT #Python #Course #IntroductionCourse

TODAY

  • course info
  • what is computation
  • python basics
  • mathematical operations
  • python variables and types
@amelieykw
amelieykw / 1 - $ vs $().md
Last active August 7, 2018 09:52
[jQuery - tutorial - jQuery Core] #jQuery #tutorial #Ajax #Event

methods that are called on a jQuery object.

$( "h1" ).remove();

several methods that do not act on a selection

  • Methods called on jQuery selections
    • automatically receive and return the selection as this.
  • Methods in the $ namespace are generally utility-type methods, and do not work with selections;
  • not automatically passed any arguments, and their return value will vary.
@amelieykw
amelieykw / Django传递数据给JS.md
Last active August 6, 2018 08:54
[Django传递数据给JS] #Django #js

Django传递数据给JS

把一个 list 或 dict等 JSON对象 传到网页的 javascript, 用 JS 进行处理,比如用 js 将数据可视化显示到网页上

如果不需要处理,直接显示到网页上,用Django模板就可以了

  1. 页面加载完成后,在页面上操作,在页面上通过 ajax 方法得到新的数据(再向服务器发送一次请求)并显示在网页上
    • 页面不刷新的情况下,动态加载一些内容
  2. 用户输入一个值或者点击某个地方,动态地把相应内容显示在网页上
    • 直接在视图函数(views.py中的函数)中将 JSON对象 和网页其它内容一起传递到Django模板(一次性地渲染,还是同一次请求)。
@amelieykw
amelieykw / Sessions framework.md
Last active August 6, 2018 14:47
[Django - Sessions framework] #Session #Django
@amelieykw
amelieykw / 0 - Stateless applications.md
Last active August 1, 2018 09:05
[Cookies and Sessions] #Cookie #Session
  • Web application servers are generally "stateless":
    • Each HTTP request is independent; server can't tell if 2 requests came from the same browser or user.
    • Web server applications maintain no information in memory from request to request (only information on disk survives from one request to another).
  • Statelessness not always convenient for application developers: need to tie together a series of requests from the same user.
@amelieykw
amelieykw / 0 - What is Cookie?.md
Last active August 1, 2018 08:53
[Cookie - tutorial] #Cookie
@amelieykw
amelieykw / 0 - 目录.md
Last active December 27, 2018 05:11
[RDBMS - 写给开发者看的关系型数据库设计] #RDBMS #写给开发者看的关系型数据库设计
@amelieykw
amelieykw / Section 01. Getting started with MySQL.md
Last active January 31, 2023 15:34
[MySQL - tutorial] #MySQL #queryingData #updatingData #managingDatabase #creatingTables

This section helps you get started with MySQL. We will start installing MySQL, downloading a sample database, and loading data into the MySQL server for practicing.

@amelieykw
amelieykw / How to decrypt hash stored by bcrypt?.md
Created July 27, 2018 14:38
[Python - decrypt hash stored by bcrypt] #Python #Bcrypt #decrypt

You're HASHING, not ENCRYPTING!

What's the difference?

The difference is that hashing is a one way function, where encryption is a two-way function.

So, how do you ascertain that the password is right?

Therefore, when a user submits a password, you don't decrypt your stored hash, instead you perform the same bcrypt operation on the user input and compare the hashes. If they're identical, you accept the authentication.

Should you hash or encrypt passwords?

@amelieykw
amelieykw / What is the Pythonic way of storing credentials in code?.md
Created July 27, 2018 14:36
[Django - What is the Pythonic way of storing credentials in code?] #Django #Python #storeCredentialsInCode

Question

To further elaborate on my question, imagine you are working on a Python project that needs a password to connect to a database, or a "client secret" to connect to a webservice. Where is the best place to store that information so that you don't inadvertently share it when distributing code?

The most common pattern I've seen is to embed it directly in the Python script, but then leave it blank, with a comment to fill it in yourself.

consumer_secret='' #Fill this in with your own credentials

Coming from PHP, the standard method was to store credentials as variables in a separate file, and then import to a script. That way you could easily "gitignore" that file, but I don't see this very often in Python.

Answers