Skip to content

Instantly share code, notes, and snippets.

✍️
Writing hieroglyphs

Pratyush Singh singhpratyush

✍️
Writing hieroglyphs
Block or report user

Report or block singhpratyush

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@singhpratyush
singhpratyush / rc.py
Created Oct 30, 2018
Steem Resource Credits for a User
View rc.py
import beem
from datetime import datetime
def get_resource_credits(username):
client = beem.Steem()
rc = beem.rc.RC(steem_instance=client)
account = beem.account.Account(username).json()
comment_requirement = rc.comment()
@singhpratyush
singhpratyush / webpack.config.dev.js
Last active Nov 11, 2019
Webpack configurations from CRA to use SCSS modules
View webpack.config.dev.js
'use strict';
const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
View partial_serve_flask_3.py
def generate_data_from_response(resp, chunk=2048):
for data_chunk in resp.iter_content(chunk_size=chunk):
yield data_chunk
def serve_partial(url, range_header, mime, size=3145728):
from_bytes, until_bytes = range_header.replace('bytes=', '').split('-')
if not until_bytes:
until_bytes = int(from_bytes) + size # Default size is 3MB
View partial_serve_flask_2.py
range_header = request.headers.get('Range', None)
if range_header:
from_bytes, until_bytes = range_header.replace('bytes=', '').split('-')
if not until_bytes: # No until bytes is set, set it to start + 3MB
until_bytes = int(from_bytes) + int(1024 * 1024 * 3) # 1MB * 3 = 3MB
# Get only what required from YouTube
headers = {'Range': 'bytes=%s-%s' % (from_bytes, until_bytes)}
r = requests.get(url, headers=headers)
data = r.content
View partial_serve_flask_1.py
r = requests.get(url)
range_header = request.headers.get('Range', None)
if range_header: # Client has requested for partial content
size = int(r.headers.get('content-length')) # Actual size of song
# Look up for ranges
m = re.search('(\d+)-(\d*)', range_header)
g = m.groups()
byte1, byte2 = 0, None
if g[0]:
View partial_content.py
@app.after_request
def after_request(response):
response.headers.add('Accept-Ranges', 'bytes')
return response
View steemLoginExample.js
import steem from 'steem';
// Get the form values
let username = document.getElementById('steem-username').value;
let privatePostingKey = document.getEmenentById('steem-posting-key').value;
// Get user details
steem.api.getAccounts([username], (err, result) => {
if (err) {
// Something went wrong
View response.md
I  [2017-09-09 14:53:35,843][WARN ][cluster.action.shard     ] [Controller] [messages_week][4] received shard failed for [messages_week][4], node[3cz-CBk5Ro-0MCy0A9cp6A], [P], v[137], s[INITIALIZING], a[id=2gM_hcRETP2Eg2vsAjJkyQ], unassigned_info[[reason=ALLOCATION_FAILED], at[2017-09-09T14:52:56.492Z], details[failed recovery, failure IndexShardRecoveryException[failed to recovery from gateway]; nested: EngineCreationFailureException[failed to recover from translog]; nested: EngineException[failed to recover from translog]; nested: TranslogCorruptedException[translog corruption while reading from stream]; nested: TranslogCorruptedException[translog stream is corrupted, expected: 0x64332db9, got: 0x74223a30]; ]], indexUUID [vhW2TG5uTHiYPUwNZRJSiQ], message [failed recovery], failure [IndexShardRecoveryException[failed to recovery from gateway]; nested: EngineCreationFailureException[failed to recover from translog]; nested: EngineException[failed to recover from translog]; nested: TranslogCorruptedExcepti
View [GSoC 2017] [FOSSASIA] Work Product Submission for loklak - singhpratyush.md
@singhpratyush
singhpratyush / priority_kaizen_score.py
Created Jul 11, 2017
A plot to visualise the score for a Tweet with various properties in loklak's PriorityKaizen harvester
View priority_kaizen_score.py
import numpy
from matplotlib import pyplot
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
x = numpy.arange(0, 30, 0.1)
y = numpy.arange(0, 30, 0.1)
x, y = numpy.meshgrid(x, y)
You can’t perform that action at this time.