Skip to content

Instantly share code, notes, and snippets.

Avatar

ademidun

View GitHub Profile
@ademidun
ademidun / useful-javascript-utils.js
Created Aug 5, 2020
Useful javascript utility functions to make your life easier.
View useful-javascript-utils.js
function prettifyKeys(rawKey) {
return toTitleCase(rawKey.replace(/_/g, ' ' ));
}
function toTitleCase(str) {
var i, j, lowers, uppers;
str = str.replace(/([^\W_]+[^\s-]*) */g, function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
@ademidun
ademidun / speculation_fund.py
Last active Jun 10, 2020
Austrian quant code snippet
View speculation_fund.py
"""
This is a template algorithm on Quantopian for you to adapt and fill in.
@author: Tomiwa Ademidun
@souce: https://github.com/ademidun/austrian-quant/blob/89593c86935ce08937aca79347902a7f93dee279/quantopian/speculation_fund.py
"""
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC, LinearSVC, NuSVC
from sklearn.ensemble import RandomForestClassifier
@ademidun
ademidun / django-cloud-9.md
Last active Sep 26, 2020
Set up Django on Cloud 9 or Fedora
View django-cloud-9.md
@ademidun
ademidun / how-to-make-website.js
Created May 3, 2020
Code samples from my How to Make a website tutorial
View how-to-make-website.js
setTimeout( () => {
$( "#name-title" ).html( "<h1>🔥</h1>" );
}, 2000);
@ademidun
ademidun / aws-secrets-manager-code-sample.py
Created Apr 11, 2020
Sample code View a code sample that illustrates how to retrieve the secret in your application.
View aws-secrets-manager-code-sample.py
# Use this code snippet in your app.
# If you need more information about configurations or implementing the sample code, visit the AWS docs:
# https://aws.amazon.com/developers/getting-started/python/
import boto3
import base64
from botocore.exceptions import ClientError
def get_secret():
@ademidun
ademidun / json-pretty-print.sh
Created Nov 16, 2019
Pretty Print a JSON file with bash and python
View json-pretty-print.sh
#source: https://stackoverflow.com/a/1920585/5405197
# With Python 2.6+ you can just do:
echo '{"foo": "lorem", "bar": "ipsum"}' | python -m json.tool
#or, if the JSON is in a file, you can do:
python -m json.tool my_json.json
#if the JSON is from an internet source such as an API, you can use
@ademidun
ademidun / python-django.py
Created Jul 31, 2019
Useful commands for Django
View python-django.py
# use this if you want to delete a specific number of entries
# https://stackoverflow.com/questions/13248593/django-database-delete-specific-number-of-entries
HomeImage.objects.filter(pk__in=HomeImage.objects.filter(ImageVectors={}).values_list('pk')[:5000])#.delete()
@ademidun
ademidun / iframe-embed.html
Last active Jul 24, 2019
Embed Youtube and Spotify iframe
View iframe-embed.html
<iframe src="//www.youtube.com/embed/_youtube_id_" width="560" height="315" frameborder="0"
allowfullscreen="allowfullscreen">
</iframe>
<iframe class="i-amphtml-fill-content" style="z-index: 0; width: 500px; height: 200px;"
src="https://open.spotify.com/embed/show/0m74ZmCPgjvp5WGOMg3P9C#amp=1"
name="amp_iframe0" width="src=" frameborder="0" sandbox="allow-scripts allow-same-origin">
</iframe>
@ademidun
ademidun / bash-git-commands.sh
Last active Aug 10, 2019
Useful Bash and Git Commands
View bash-git-commands.sh
# Rename File Extensions
# https://www.maketecheasier.com/rename-files-in-linux/
brew install rename;
rename 's/.m4a/.mp3/' * # rename all .m4a files to .mp3 (don't forget to include the asteriks '*')
# delete all files with a certain extension
# https://askubuntu.com/questions/377438/how-can-i-recursively-delete-all-files-of-a-specific-extension-in-the-current-di
find . -name "*.bak" -type f #first check the files that will be deleted
find . -name "*.bak" -type f -delete # then you can delete them
@ademidun
ademidun / pwa-tutorial-0-0-main.ts
Last active Sep 28, 2018
Service worker configuration for Part 1 if Angular pwa tutorial.
View pwa-tutorial-0-0-main.ts
// src/main.ts
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
You can’t perform that action at this time.