Skip to content

Instantly share code, notes, and snippets.

View Se7soz's full-sized avatar

Hussein Elsayed Se7soz

View GitHub Profile
@Se7soz
Se7soz / gist:1541091
Created December 30, 2011 19:16
servers/apfs/buffer.c: fixed put_block call to find_block instead of get_block that creates the block if it doesn't exist.
commit 4d7f4a5e3b9561f37ee5f61727e7b48c3065c446
Author: Hussein El-Sayed <[email protected]>
Date: Fri Dec 30 23:28:15 2011 +0000
servers/apfs/buffer.c: fixed put_block call to find_block instead of get_blo
that creates the block if it doesn't exist.
diff --git a/servers/apfs/buffer.c b/servers/apfs/buffer.c
index a5c77b4..de18e8c 100644
--- a/servers/apfs/buffer.c
@Se7soz
Se7soz / lazy_segment_tree.cpp
Last active May 9, 2024 18:35
An example for lazy segment trees.. to read full topic visit http://se7so.blogspot.com
/**
* In this code we have a very large array called arr, and very large set of operations
* Operation #1: Increment the elements within range [i, j] with value val
* Operation #2: Get max element within range [i, j]
* Build tree: build_tree(1, 0, N-1)
* Update tree: update_tree(1, 0, N-1, i, j, value)
* Query tree: query_tree(1, 0, N-1, i, j)
*/
#include<iostream>
@Se7soz
Se7soz / segment_tree.cpp
Last active July 11, 2019 07:27
An example of segment tree implementation, to read the whole topic please visit http://se7so.blogspot.com
/**
* In this code we have a very large array called arr, and very large set of operations
* Operation #1: Increment the elements within range [i, j] with value val
* Operation #2: Get max element within range [i, j]
* Build tree: build_tree(1, 0, N-1)
* Update tree: update_tree(1, 0, N-1, i, j, value)
* Query tree: query_tree(1, 0, N-1, i, j)
*/
#include<iostream>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;
int main() {
int n;
cin >> n;
@Se7soz
Se7soz / workers.properties
Created March 7, 2013 14:24
workers.properties
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13) # Don't use ajp12 because it has lots of bugs
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
@Se7soz
Se7soz / httpd.conf
Created March 7, 2013 14:28
httpd.conf
JkWorkersFile /usr/local/apache2/conf/workers.properties
# Where to put jk logs
JkLogFile /usr/local/apache2/logs/jk_error
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
@Se7soz
Se7soz / itext_renderer
Created April 22, 2013 09:10
IText renderer code
private void convertHtmlToPdf(File inputFile, File outputFile) throws IOException, FileNotFoundException, DocumentException {
String path = inputFile.toURI().toURL().toString();
ITextRenderer renderer = new ITextRenderer();
ITextFontResolver fr = renderer.getFontResolver();
fr.addFont(properties.getProperty("itext.fonts.lucidaFontPath"), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.setDocument(path);
renderer.layout();
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
int mem[50][50][50]; // Memorize visited states
void eval(const int& x, int &y, int &z) {
if(x != -1) {
y++;
@Se7soz
Se7soz / prob1.cpp
Last active January 3, 2016 05:09
Read the How to prepare for an interview series at my blog: http://se7so.blogspot.com/2014/01/how-to-prepare-for-interview.html
bool hasUniqueChs(string s) {
bool chs[256];
memset(chs, false, sizeof chs);
for(int i = 0; i < s.size(); i++) {
if(chs[s[i]])
return false;
chs[s[i]] = true;
}
@Se7soz
Se7soz / prob2.cpp
Last active January 3, 2016 05:09
Read the How to prepare for an interview series at my blog: http://se7so.blogspot.com/2014/01/how-to-prepare-for-interview.html
string reverse(string s) {
int len = s.size();
for(int i = 0; i < len/2; i++) {
swap(s[i], s[len-i-1]);
}
return s;
}