Skip to content

Instantly share code, notes, and snippets.

View szolotykh's full-sized avatar
😀

Sergey Zolotykh szolotykh

😀
View GitHub Profile
@szolotykh
szolotykh / strmerge.c
Created April 19, 2013 04:17
Merge two strings. Note: Don't forget to free memory after using function.
char* strmerge(char* str1, char* str2){
char* str = (char*)malloc(strlen(str1) + strlen(str2) + 1);
strcpy(str, str1);
strcat(str, str2);
return str;
}
@szolotykh
szolotykh / intToStr.c
Created April 19, 2013 04:21
Int to string function. Note: Don't forget to free the memory after using function
char* intToStr(int num){
char* str = (char*)malloc(12);
sprintf(str, "%d", num);
return str;
}
@szolotykh
szolotykh / char2wchar_t.cpp
Last active December 16, 2015 23:49
Function of converting char to wchar_t
//Convert char to wchar_t
bool char2wchar_t(char *str1, wchar_t *str2){
std::wstringstream st;
st << str1;
return !(st >> str2).fail();
};
class listNode{
public:
listNode *previous;
listNode *next;
int val;
bool remove(){
this->previous->next=this->next;
this->next->previous=this->previous;
delete this;
return true;
// Priority Queue
function PriorityQueue(){
this.list = new Array()
this.push = function(el, priority){
this.list.push([el, priority]);
}
this.pop = function(){
if(this.list.length == 0)
return null;
var minPriority = this.list[0][1];
@szolotykh
szolotykh / collision.js
Last active May 30, 2019 02:48
JavaScript collision library
/* File comments updated: Sunday, March 25, 2012 at 12:38 AM
*
* COLLISION SYSTEM: provides functions to create collision objects
* and detect collisions between objects and points.
* Used by most animated objects on the canvas to detect collisions.
*/
// POINT: contains an x and y position
function Point(x, y){
this.x = x;
#include <iostream>
#include <string>
using namespace std;
bool BracketsInclusion(string str){
int length = str.length();
// Remove everything besides brackets
string bstr ="";
for(int i = 0; i<length; i++){
@szolotykh
szolotykh / twitter-post.py
Last active August 29, 2015 14:01
Python script is update status on twitter
import tweepy
import os
# Consumer keys and access tokens, used for OAuth
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
# OAuth process, using the keys and tokens
@szolotykh
szolotykh / twitter-stream.py
Created May 23, 2014 05:22
Tweets streaming
import tweepy
import os
import json
# Consumer keys and access tokens
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
from urllib2 import Request, urlopen, URLError
def findURL(page_srt, res):
try:
att = "url"+res
start_ind = page_srt.index(att)
end_ind = page_srt.index("?",start_ind)
url = page_srt[(start_ind+len(att)+1):end_ind]
return url
except: