This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <ctype.h> | |
int main(void) { | |
// define a string (or get from user input) | |
char *s = "santosh"; | |
// copy that string into memory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from abc import ABC, abstractmethod | |
class AbstractRecipe(ABC): | |
def execute(self): | |
self.prepare() | |
self.recipe() | |
self.cleanup() | |
@abstractmethod | |
def prepare(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
# print(re.split(r'(s*)', 'here are some words')) | |
# print(re.split(r'[a-f]', 'kjfsldhjakcnv', re.I | re.M)) | |
print(re.findall(r'\d', 'ocinwe324 main st.asdvce')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In this script, we'll overload '+' operator to add two classes. | |
class CurrenciesDoNotMatchError(TypeError): | |
def __init__(self, message): | |
super().__init__(message) | |
class Currency: | |
def __init__(self, currency, amount): | |
self.currency = currency |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <opencv2/opencv.hpp> | |
#include <iostream> | |
using namespace std; | |
using namespace cv; | |
int main(void) { | |
// capture a video, for webcam, pass 0 instead of file path.. | |
VideoCapture cap(0); | |
if (!cap.isOpened()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
File: ageinhours.py | |
Author: Santosh Kumar | |
Email: [email protected] | |
Github: @santosh | |
Description: Calculate age in seconds | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Singleton is something I have already used in Game Development with Unity. | |
class MySingleton(object): | |
"""docstring for MySingleton""" | |
_instance = None | |
def __new__(self): | |
if not self._instance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
def addOne(oldFunc): | |
def addOneInside(*args, **kwargs): | |
return oldFunc(*args, **kwargs) + 1 | |
return addOneInside | |
@addOne | |
def someFunct(x): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
def arguments(*args): | |
for i in args: | |
print(i) | |
l = [1, 2, 3, 5] | |
# arguments(1, 2, 3, 5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- Bookstore with DTD --> | |
<!-- Try changes: --> | |
<!-- Make Edition required --> | |
<!-- Swap order of First_Name, Last_Name --> | |
<!-- Add empty Remark --> | |
<!-- Add Magazine, omit closing tag --> | |
<!DOCTYPE Bookstore [ | |
<!ELEMENT Bookstore (Book | Magazine)*> | |
<!ELEMENT Book (Title, Authors, Remark?)> |