Skip to content

Instantly share code, notes, and snippets.

@abhi1010
abhi1010 / mailer.py
Created September 24, 2018 06:26
send mails
import httplib2
from email.encoders import encode_base64
from apiclient import discovery
from oauth2client import client
from oauth2client import tools
from oauth2client.file import Storage
import base64
from email.mime.audio import MIMEAudio
from email.mime.base import MIMEBase
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
@abhi1010
abhi1010 / gist:04ae5e63af2fd629000965b47865521d
Created October 25, 2018 03:34 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: πŸ˜„ :smile: πŸ˜† :laughing:
😊 :blush: πŸ˜ƒ :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
πŸ˜† :satisfied: 😁 :grin: πŸ˜‰ :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: πŸ˜€ :grinning:
πŸ˜— :kissing: πŸ˜™ :kissing_smiling_eyes: πŸ˜› :stuck_out_tongue:
@abhi1010
abhi1010 / multi-line-replace-perl.md
Created November 28, 2018 05:12
multi line replace in bash

How to do a multi-line replace in files

Remember to add a backslash for special keywords like //{

perl -i -p0e 's/namespace gng \{\nnamespace strategy \{/namespace gng::engine::xraider \{/igs' *.h

perl -i -p0e 's/namespace gng \{\nnamespace strategy \{/namespace gng::engine::xraider \{/igs' *.cc
@abhi1010
abhi1010 / MigrateFromGoogleTestToCatch.py
Created August 21, 2019 05:51
Helper script to migrate from Google Test to Catch
import sys
import re
import os
testCaseRegex = re.compile (r'TEST\s*\((\w+),\s*(\w+)\)')
expectRegex = re.compile (r'EXPECT_(\w+)\s*\((.*)\);')
assertRegex = re.compile (r'ASSERT_(\w+)\s*\((.*)\);')
leadingWhitespaceRegex = re.compile(r'^(\s*)')
module = "[unknown]"
@abhi1010
abhi1010 / run_cmd.py
Created November 13, 2019 02:45
run bash commands on python
import logging
import sys
import argparse
import subprocess
import os
import logging.handlers
from typing import List, Union, Dict, Tuple, Sequence
import utils
from datetime import datetime, timedelta
@abhi1010
abhi1010 / mock.methods.py
Created April 23, 2023 14:58 — forked from Sklavit/mock.methods.py
Mock examples
# @ https://cheat.readthedocs.io/en/latest/python/mock.html
obj.call_count # number of times it was called
obj.called == obj.call_count > 0
obj.call_args_list # a list of (args,kwargs), one for each call
obj.call_args # obj.call_args_list[-1] (args,kwargs from last call)
obj.return_value # set to what it should return
obj.side_effect # set to an exception class or instance that should be raised when its called
obj.assert_called() # doesn't work with autospec=True? just assert obj.called
obj.assert_called_with(*args, **kwargs) # last call was with (*args, **kwargs)
@abhi1010
abhi1010 / mean_reversion.ipynb
Created July 17, 2023 15:01 — forked from AnthonyFJGarner/mean_reversion.ipynb
A Simple Mean Reversion System in Simple Python Code
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.