Skip to content

Instantly share code, notes, and snippets.

#include <sstream>
stringstream ss;
string s; //main string
string newString; //new string
ss << s; //assign s to ss
while(ss >> newString) { // Spilit string
@s1s1ty
s1s1ty / sample.rq
Last active January 18, 2021 01:46
PREFIX ab: <http://learningsparql.com/ns/addressbook#>
SELECT ?name
WHERE {
?name ab:email "richard49@hotmail.com" .
}
@prefix ab: <http://learningsparql.com/ns/addressbook#> .
ab:ali_gatie ab:borns "Yemen" .
ab:ali_gatie ab:homeTel "01700000" .
ab:ali_gatie ab:email "ali_gatie@hotmail.com" .
# If we want to add more person...
ab:richard ab:borns "Berlin" .
ab:richard ab:homeTel "01700001" .
ab:richard ab:email "richard49@hotmail.com" .
@s1s1ty
s1s1ty / sample.ttl
Last active January 18, 2021 00:44
@prefix ab: <http://learningsparql.com/ns/addressbook#> .
ab:ali_gatie ab:borns "Yemen" ;
ab:homeTel "01700000" ;
ab:email "ali_gatie@hotmail.com" .
# If we want to add more person...
ab:richard ab:borns "Berlin" ;
ab:homeTel "01700001" ;
ab:email "richard49@hotmail.com" .
@s1s1ty
s1s1ty / logstash-export-csv.conf
Created December 27, 2018 15:23
export elastic to csv
input {
elasticsearch {
hosts => "localhost:9200"
index => "give_index_name"
query => '
{
"query": {
"match_all": {}
}
}
# delete all data from _doc
curl -XPOST 'localhost:9200/pathao/zone_path/_delete_by_query?conflicts=proceed&pretty' -d'
{
"query": {
"match_all": {}
}
}'
@s1s1ty
s1s1ty / s_i.py
Created August 24, 2018 18:53
30-days-python-code
#!/bin/python3
S = input().strip()
try:
print(int(S))
except ValueError:
print('Bad String')
@s1s1ty
s1s1ty / scope.py
Created August 24, 2018 18:36
30-days-python-code
class Difference:
def __init__(self, a):
self.__elements = a
self.maximumDifference = -1
def computeDifference(self):
e = self.__elements
m = -1
for i in range(len(e)):
for j in range(i+1, len(e)):
@s1s1ty
s1s1ty / abs.py
Created August 24, 2018 18:20
30-days-python-code
from abc import ABCMeta, abstractmethod
class Book(object, metaclass=ABCMeta):
def __init__(self,title,author):
self.title=title
self.author=author
@abstractmethod
def display(): pass
@s1s1ty
s1s1ty / bi_num.py
Last active August 24, 2018 06:39
30-days-python-code
#!/bin/python3
if __name__ == '__main__':
n = int(input())
b = bin(n)[2:] # dec to binary
c = 0
a = -1
for i in b:
if i == '1':
c += 1