Skip to content

Instantly share code, notes, and snippets.

@jangedoo
jangedoo / plotlycheats.md
Last active March 27, 2023 15:04
Plotly Cheatsheet

Change template

px.bar(..., template="simple_white")

Change axis legend labels

px.bar(..., labels={"gndr": "Gender", "cnt": "Total Participants"})

Show axis ticks for feach facet

fig.for_each_xaxis(lambda xaxis: xaxis.update(showticklabels=True))

fig.for_each_yaxis(lambda yaxis: yaxis.update(showticklabels=True))

@jangedoo
jangedoo / ner_data_maker.py
Created April 13, 2022 09:40
NER dataset creator
import re
def get_tokens_with_entities(raw_text: str):
raw_tokens = re.split(r"\s(?![^\[]*\])", raw_text)
entity_value_pattern = r"\[(?P<value>.+?)\]\((?P<entity>.+?)\)"
entity_value_pattern_compiled = re.compile(entity_value_pattern, flags=re.I|re.M)
tokens_with_entities = []
for raw_token in raw_tokens:
match = entity_value_pattern_compiled.match(raw_token)
@jangedoo
jangedoo / redditcomments_sample.jsonl
Created November 11, 2019 18:15
Reddit Comments Jsonl Sample
{"all_awardings":[],"author":"bbynug","author_created_utc":1524515156,"author_flair_background_color":null,"author_flair_css_class":null,"author_flair_richtext":[],"author_flair_template_id":null,"author_flair_text":null,"author_flair_text_color":null,"author_flair_type":"text","author_fullname":"t2_10irg672","author_patreon_flair":false,"body":"JP: \u201cMen are order and women are chaos\u201d\n\nYou: Yup, makes perfect sense \n\nAlso you: Wait ok first of all when did Jordan Peterson say anything derogatory about women?","can_gild":true,"can_mod_post":false,"collapsed":false,"collapsed_reason":null,"controversiality":0,"created_utc":1559347200,"distinguished":null,"edited":false,"gilded":0,"gildings":{},"id":"epom079","is_submitter":false,"link_id":"t3_bvaldc","locked":false,"no_follow":false,"parent_id":"t1_epok9jx","permalink":"\/r\/iamverysmart\/comments\/bvaldc\/in_a_thread_about_old_town_road\/epom079\/","quarantined":false,"removal_reason":null,"retrieved_on":1568677945,"score":9,"send_replies":true,"
@jangedoo
jangedoo / cakefileupload.php
Last active August 5, 2016 15:18
CakePHP file upload
//in upload.ctp,
<?php echo $this->Form->input('proxyfile',array('type' => 'file', 'class' => 'btn btn-default btn-file')) ?>
//in controller
public function upload(){
$filename = WWW_ROOT . "/files/".$this->data['Proxy']['proxyfile']['name'];
/* copy uploaded file */
if (move_uploaded_file($this->data['Proxy']['proxyfile']['tmp_name'],$filename)) {
/* save message to session */
@jangedoo
jangedoo / dynamic_scheduling.c
Created March 5, 2016 15:32
Dynamic Scheduling in OpenMP
void dynamic_scheduling(){
printf("Dynamic Scheduling demo...\n");
int N = 16;
int i;
printf("Using static scheduling\n");
auto t1 = Clock::now();
#pragma omp parallel for num_threads(4) schedule(static, 2)
for (i = 0; i < N; i++){
printf("Thread no = %d, i = %d\n", omp_get_thread_num(), i);
@jangedoo
jangedoo / staticscheduling.c
Last active March 5, 2016 14:43
Static Scheduling in OpenMP with chunk size
void static_scheduling(){
printf("Static Scheduling demo...\n");
int N = 30;
int i;
#pragma omp parallel for num_threads(7) schedule(static, 2)
for (i = 0; i < N; i++){
printf("Rank is %d, i is %d\n", omp_get_thread_num(), i);
}