Skip to content

Instantly share code, notes, and snippets.

@hammedb197
hammedb197 / .tsx
Created December 17, 2022 13:17 — forked from dragosbulugean/.tsx
crisp
import * as React from 'react'
import { UserResponse } from '../shared/UserAPI'
import { getWindowVar } from './util'
export class CrispChat extends React.Component<{ user?: UserResponse }> {
async componentDidMount() {
// @ts-ignore
if (typeof window !== 'undefined' && !window['$crisp']) {
this.addMainScript()
}
import json
from time import sleep
from bs4 import BeautifulSoup
from kafka import KafkaConsumer, KafkaProducer
def publish_message(producer_instance, topic_name, key, value):
try:
key_bytes = bytes(key, encoding='utf-8')
@hammedb197
hammedb197 / faster_toPandas.py
Created August 20, 2020 17:14 — forked from joshlk/faster_toPandas.py
PySpark faster toPandas using mapPartitions
import pandas as pd
def _map_to_pandas(rdds):
""" Needs to be here due to pickling issues """
return [pd.DataFrame(list(rdds))]
def toPandas(df, n_partitions=None):
"""
Returns the contents of `df` as a local `pandas.DataFrame` in a speedy fashion. The DataFrame is
repartitioned if `n_partitions` is passed.