Skip to content

Instantly share code, notes, and snippets.

View Manuel4131's full-sized avatar

alstonChang Manuel4131

View GitHub Profile

所以想請問有經驗的人是用哪一套在local端開發的呢?

local端web server應該用django附的dev server就夠了(./manage.py runserver)
DBMS的部分如果沒有用到特殊field(JSONField那類)的話應該就用SQLite就足夠了

資料如何管控,例如local 端是去存取另外一個資料庫嗎? 如果是另一個資料庫,那deploymenet的時候又要改來改去了。

  1. 你可以分成devlopment用的和production用的settings.py https://gist.github.com/andy23512/6a5c6488c2576be1bf1b659a45c380e5 這個是我為了跑自動化測試而另外寫出的test_settings.py 這樣只要在執行時附加--settings=web.test_settings就可以使用不同的settings
@legnaleurc
legnaleurc / stream.cgi
Last active July 26, 2017 05:10
streaming PoC
#! /bin/sh
echo 'Content-Type: video/mp4'
echo
ffmpeg -i 'rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov' -c:v copy -c:a copy -f mp4 -movflags frag_keyframe+empty_moov -
@webserveis
webserveis / DemoFragmentAdapter.java
Created April 27, 2017 20:16
Sincronizar ViewPager con BottomNavigationView
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;
//FragmentStatePagerAdapter
//FragmentPagerAdapter
@imminent
imminent / Api.java
Last active June 13, 2023 02:50
Call retrying with Retrofit 2.0
package com.example.api;
import java.util.Map;
import retrofit.Call;
import retrofit.http.Body;
import retrofit.http.GET;
import retrofit.http.POST;
public interface Api {
@joseluisq
joseluisq / terminal-git-branch-name.md
Last active April 20, 2024 02:26
Add Git Branch Name to Terminal Prompt (Linux/Mac)

Add Git Branch Name to Terminal Prompt (Linux/Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {

Build a scalable Twitter clone with Django and GetStream.io

In this tutorial we are going to build a Twitter clone using Django and GetStream.io, a hosted API for newsfeed development.

We will show you how easy is to power your newsfeeds with GetStream.io. For brevity we leave out some basic Django-specific code and recommend you refer you to the Github project for the complete runnable source code. At the end of this tutorial we will have a Django app with a profile feed, a timeline feed, support for following users, hashtags and mentions.

I assume that you are familiar with Django. If you're new to Django the [official tutorial] (https://docs.djangoproject.com/en/2.0/intro/) explains it very well.

@manishcm
manishcm / StateRemovableFragmentStatePageAdapter.java
Last active September 12, 2019 12:17
Enhanced version of FragmentStatePageAdapter which allows to remove the saved states, so that fragments can be recreated with new state.
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@Kartones
Kartones / postgres-cheatsheet.md
Last active May 7, 2024 17:48
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@Bouke
Bouke / gist:11261620
Last active August 3, 2023 01:46
Multiple Python installations on OS X

Previous versions used homebrew to install the various versions. As suggested in the comments, it's better to use pyenv instead. If you are looking for the previous version of this document, see the revision history.

$ brew update
$ brew install pyenv
$ pyenv install 3.5.0
$ pyenv install 3.4.3
$ pyenv install 3.3.6
$ pyenv install 3.2.6
$ pyenv install 2.7.10

$ pyenv install 2.6.9

@mziwisky
mziwisky / Oauth2.md
Last active February 15, 2024 23:31
Oauth2 Explanation

OAUTH2

The Problem

I’m a web app that wants to allow other web apps access to my users’ information, but I want to ensure that the user says it’s ok.

The Solution

I can’t trust the other web apps, so I must interact with my users directly. I’ll let them know that the other app is trying to get their info, and ask whether they want to grant that permission. Oauth defines a way to initiate that permission verification from the other app’s site so that the user experience is smooth. If the user grants permission, I issue an AuthToken to the other app which it can use to make requests for that user's info.

Note on encryption

Oauth2 has nothing to do with encryption -- it relies upon SSL to keep things (like the client app’s shared_secret) secure.