Skip to content

Instantly share code, notes, and snippets.

View firaja's full-sized avatar
💭
Do or do not. There is no try.

David Bertoldi firaja

💭
Do or do not. There is no try.
View GitHub Profile
@firaja
firaja / quicksort.py
Created March 22, 2018 07:21
Python one line Quicksort algorithm
qs = lambda l: [] if not l else qs(filter(lambda x: x <= l[0], l[1:])) + [l[0]] + qs(filter(lambda x: x > l[0], l[1:]))
@firaja
firaja / HACLoggerScanner.java
Last active July 24, 2018 15:43
HAC Logging Configuration in 6.0 and above
package your.package;
import de.hybris.platform.util.logging.log4j2.HybrisLoggerContext;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.annotation.PostConstruct;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@firaja
firaja / cose.java
Created August 3, 2018 13:33
Hybris force locale
// ciao manuello
sessionService.executeInLocalView(new SessionExecutionBody()
{
@Override
public void executeWithoutResult()
{
i18nService.setCurrentLocale(LA_TUA_LINGUA);
export(product)
}
@firaja
firaja / CustomCmsContentPagePrepareInterceptor.java
Created August 6, 2018 08:01
Hybris - solve homepage set to false in cmscockpit
public class CustomCmsContentPagePrepareInterceptor extends CmsContentPagePrepareInterceptor
{
@Override
protected void resetHomepageFlag(Collection<AbstractPageModel> contentPages, ContentPageModel currentPageModel, InterceptorContext ctx)
{
if (this.getCmsAdminPageService().getActiveCatalogVersion().equals(currentPageModel.getCatalogVersion()))
{
super.resetHomepageFlag(contentPages, currentPageModel, ctx);
}
}
@firaja
firaja / idea.vmoptions
Created August 9, 2018 16:27
IntelliJ IDEA VM Options
-server
-Xms2g
-Xmx2g
-Xss16m
-XX:+UseConcMarkSweepGC
-XX:+CMSParallelRemarkEnabled
-XX:ConcGCThreads=4
-XX:ReservedCodeCacheSize=256m
-XX:+AlwaysPreTouch
-XX:+TieredCompilation
def flipTheCoin():
while True:
t1 = notFairRandomNumber()
t2 = notFairRandomNumber()
if t1 != t2:
return t1 and 1
def wbc_caesar_cipher(message):
result = ""
I = {' ': ' ', 'a': 'y', 'c': 'a', 'b': 'z', 'e': 'c', 'd': 'b', 'g': 'e', 'f': 'd', 'i': 'g', 'h': 'f', 'k': 'i', 'j': 'h', 'm': 'k', 'l': 'j', 'o': 'm', 'n': 'l', 'q': 'o', 'p': 'n', 's': 'q', 'r': 'p', 'u': 's', 't': 'r', 'w': 'u', 'v': 't', 'y': 'w', 'x': 'v', 'z': 'x'}
O_inverse = {' ': ' ', 'a': 'h', 'c': 'j', 'b': 'i', 'e': 'l', 'd': 'k', 'g': 'n', 'f': 'm', 'i': 'p', 'h': 'o', 'k': 'r', 'j': 'q', 'm': 't', 'l': 's', 'o': 'v', 'n': 'u', 'q': 'x', 'p': 'w', 's': 'z', 'r': 'y', 'u': 'b', 't': 'a', 'w': 'd', 'v': 'c', 'y': 'f', 'x': 'e', 'z': 'g'}
P = {' ': ' ', 'a': 'p', 'c': 'r', 'b': 'q', 'e': 't', 'd': 's', 'g': 'v', 'f': 'u', 'i': 'x', 'h': 'w', 'k': 'z', 'j': 'y', 'm': 'b', 'l': 'a', 'o': 'd', 'n': 'c', 'q': 'f', 'p': 'e', 's': 'h', 'r': 'g', 'u': 'j', 't': 'i', 'w': 'l', 'v': 'k', 'y': 'n', 'x': 'm', 'z': 'o'}
Q = {' ': ' ', 'a': 'j', 'c': 'l', 'b': 'k', 'e': 'n', 'd': 'm', 'g': 'p', 'f': 'o', 'i': 'r', 'h': 'q', 'k': 't', 'j': 's
def wbc_caesar_cipher(message):
result = ""
look_up_table = {"a" : "d", "b" : "e", "c" : "f", "d" : "g", "e" : "h", ...}
for m in message:
result += look_up_table[m]
return result
def caesar_cipher(message, key):
result = ""
for m in message:
result += chr((ord(m) + key - 97) % 26 + 97)
return result
look_up_table = {
'a' : 'd',
'b' : 'e',
'c' : 'f',
'd' : 'g',
'e' : 'h',
...
}