Skip to content

Instantly share code, notes, and snippets.

View ErickMwazonga's full-sized avatar
🎯
The Unfolding

Erick Mwazonga ErickMwazonga

🎯
The Unfolding
View GitHub Profile
@ErickMwazonga
ErickMwazonga / gist:3e50b4743d1a5a6546dfd758268d0211
Created September 26, 2018 07:38 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
# List unique values in a DataFrame column
# h/t @makmanalp for the updated syntax!
df['Column Name'].unique()
# Convert Series datatype to numeric (will error if column has non-numeric values)
# h/t @makmanalp
pd.to_numeric(df['Column Name'])
# Convert Series datatype to numeric, changing non-numeric values to NaN
# h/t @makmanalp for the updated syntax!
import random
def _generate_cart_id():
cart_id = ''
characters = 'ABCDEFGHIJKLMNOPQRQSTUVWXYZabcdefghiklmnopqrstuvwxyz1234567890!@#$%^&*()'
cart_id_length = 50
for y in range(cart_id_length):
cart_id += characters[random.randint(0, len(characters)-1)]
class FeedbackFormView(FormView):
form_class = FeedbackForm
template_name = 'ecoke/feedback.html'
def get_initial(self):
if self.request.user.is_authenticated():
return {
'name': self.request.user.profile.get_screen_name,
'email': self.request.user.email,
}
@ErickMwazonga
ErickMwazonga / pipeline.py
Last active January 14, 2018 20:15
django-pipeline
# Pipeline
# PIPELINE_ENABLED = True
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'pipeline.finders.CachedFileFinder',
'pipeline.finders.PipelineFinder',
@ErickMwazonga
ErickMwazonga / nginx.conf
Last active October 5, 2018 12:10
Deploy
# https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-16-04
# configuration of the server
server {
# the port your site will be served on
listen 80;
listen [::]:80;
# the domain name it will serve for
server_name 192.168.2.212;
charset utf-8;
@ErickMwazonga
ErickMwazonga / hashing.py
Created December 21, 2017 21:29
Hashing
import uuid
import hashlib
def hash_password(password):
# uuid is used to generate a random number
salt = uuid.uuid4().hex
return hashlib.sha256(salt.encode() + password.encode()).hexdigest() + ':' + salt
def check_password(hashed_password, user_password):
password, salt = hashed_password.split(':')
@ErickMwazonga
ErickMwazonga / inline.css
Last active December 20, 2017 23:46
Inline css
/* -------------------------------------
GLOBAL
A very basic CSS reset
------------------------------------- */
* {
margin: 0;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
box-sizing: border-box;
font-size: 14px;
}
@ErickMwazonga
ErickMwazonga / feedback_mail_admins.py
Last active December 14, 2017 15:46
feedback_mail_admins.py
from django.core.mail import mail_admins
def feedback(request):
if request.method == 'POST':
f = FeedbackForm(request.POST)
if f.is_valid():
name = f.cleaned_data['name']
sender = f.cleaned_data['email']
subject = "You have a new Feedback from {}:{}".format(name, sender)
message = "Subject: {}\n\nMessage: {}".format(f.cleaned_data['subject'], f.cleaned_data['message'])
@ErickMwazonga
ErickMwazonga / example.html
Created December 6, 2017 20:53 — forked from vitorfs/example.html
Django Bootstrap Pagination Widget
<table class="table table-bordered">
<thead>
<tr>
<th>Title</th>
<th>Author</th>
<th>Date</th>
</tr>
</thead>
<tbody>
{% for article in articles %}