Rails is really a collection of pieces that can be put together to create a web app. You can enhance or replace many of the components - how you write views, how controllers work, and how you build models. While models are built on top of ActiveRecord in the
This file contains hidden or 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
| <div {% if not widget.attrs.style %}style="height:{{widget.height|default:'500px'}};width:{{widget.width|default:'90%'}};display:inline-block;"{% endif %}{% include "django/forms/widgets/attrs.html" %}></div> | |
| <script> | |
| (function() { | |
| var container = document.getElementById("{{ widget.attrs.id }}"); | |
| var options = {{ widget.options|safe }}; | |
| options.onModeChange = function (newMode, oldMode) { | |
| if (newMode === 'code') { | |
| editor.aceEditor.setReadOnly(true); |
This file contains hidden or 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
| [alias] | |
| # Basically `log --oneline --decorate --graph` with different colors and some additional info (author and date) | |
| lg = log --graph --abbrev-commit --decorate --format=format:'%C(yellow)%h%C(reset) %C(normal)%s%C(reset) %C(dim white)%an%C(reset) %C(dim blue)(%ar)%C(reset) %C(dim black)%d%C(reset)' | |
| # lg (see above) with --first-parent | |
| lgp = log --graph --abbrev-commit --decorate --format=format:'%C(yellow)%h%C(reset) %C(normal)%s%C(reset) %C(dim white)%an%C(reset) %C(dim blue)(%ar)%C(reset) %C(dim black)%d%C(reset)' --first-parent | |
| # https://stackoverflow.com/questions/61510067/show-specific-commits-in-git-log-in-context-of-other-commits | |
| hl = "!f() { cd -- ${GIT_PREFIX:-.}; grep --color -E \"$(git log --pretty=%h \"$@\" | tr '\n' '|')\" || true; }; f" | |
| hlp = "!f() { cd -- ${GIT_PREFIX:-.}; less -R -p $(git log --pretty=%h \"$@\" | tr '\n' '|'); }; f" |
This file contains hidden or 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
| """Script to download free O'Reilly ebooks.""" | |
| import asyncio | |
| import os | |
| import re | |
| import sys | |
| import aiohttp | |
| filename_matcher = re.compile(r'http://www.oreilly.com/(.*)/free/(.*).csp') | |
| session = None |
This file contains hidden or 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
| def generate_cpf(self): | |
| cpf = [random.randint(0, 9) for x in range(9)] | |
| for _ in range(2): | |
| val = sum([(len(cpf) + 1 - i) * v for i, v in enumerate(cpf)]) % 11 | |
| cpf.append(11 - val if val > 1 else 0) | |
| return '%s%s%s.%s%s%s.%s%s%s-%s%s' % tuple(cpf) |
This file contains hidden or 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
| #!/usr/bin/env bash | |
| # | |
| # This is sp, the command-line Spotify controller. It talks to a running | |
| # instance of the Spotify Linux client over dbus, providing an interface not | |
| # unlike mpc. | |
| # | |
| # Put differently, it allows you to control Spotify without leaving the comfort | |
| # of your command line, and without a custom client or Premium subscription. | |
| # |
This file contains hidden or 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
| ====================================== | |
| Setting up Nginx, uWSGI and Python3 | |
| ====================================== | |
| First off, I'm traditionally a PHP developer, but am looking at moving across to Python. I really struggled to find decent documentation on how to get a server up and running for deploying Python web applications from the point of view of someone coming from PHP. The main problems I came across with documentation were: | |
| 1) Only showed you how to run the server for a single web application. | |
| 2) Only showed you how to configure the app, not the server it was running on. | |
| My preferred workflow for development is by setting up a new VM in VMware Fusion and then forwarding through all requests to that VM via /etc/hosts. This might not be the optimal way to get things up and running, but it works for me. |
NewerOlder