Skip to content

Instantly share code, notes, and snippets.

View mutairibassam's full-sized avatar
💭
Coding...

Bassam A. mutairibassam

💭
Coding...
View GitHub Profile
const pipeline_using_match_group = [
// Stage 1: match the accounts with a balance greater than $1,000
{ $match: { balance: { $lt: 1000 } } },
// Stage 2: Calculate average balance and total balance
{
$group: {
_id: "$account_type",
total_balance: { $sum: "$balance" },
avg_balance: { $avg: "$balance" },
},
public abstract TodoDao todoDao();
//Create the WordRoomDatabase as a singleton to prevent having multiple instances of the database opened
//at the same time, which would be a bad thing
private static TodoDatabase INSTANCE;
public static final String DATABASE_NAME = "TASK_DATABASE";
// singlton: to make sure there is no more than one copy
// @synchronized one thread only can deal with this database
public static synchronized TodoDatabase getInstance(Context context) {
@mutairibassam
mutairibassam / jupyter-cell-tips.py
Last active December 20, 2020 18:14
jupyter-cell-tips
# Tip 1
# to print all the interactive output, not only the last result.
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
################################################################################
# Tips 2
# get_option() / set_option() - get/set the value of a single option.
pd.get_option("display.max_rows") # return max_rows value
@mutairibassam
mutairibassam / slides-nbconvert.sh
Last active December 18, 2020 20:17
convert-notebook-to-slides
# In your terminal, replace NOTEBOOK_NAME with the name of your notebook
jupyter nbconvert NOTEBOOK_NAME.ipynb --to slides --post serve
jupyter nbconvert NOTEBOOK_NAME.ipynb --to html
@mutairibassam
mutairibassam / output_toggle.tpl
Created December 16, 2020 06:21
hide the input cells from your ipython slides
{# Jupyter Notebook Toggle Template for Slides by Damian Avila
from http://www.damian.oquanta.info/posts/hide-the-input-cells-from-your-ipython-slides.html
#}
{%- extends 'slides_reveal.tpl' -%}
{% block input_group -%}
<div class="input_hidden">
{{ super() }}
</div>
@mutairibassam
mutairibassam / jupyter-toggle.py
Last active December 17, 2020 06:15
To toggle on/off the raw code in jupyter notebook.
# hiding code for proper presentation
from IPython.display import HTML
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}