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 / prng.py
Created November 10, 2019 18:17
Building a Pseudorandom Number Generator
import sys
SEED_SIZE = 16
GENERATOR = 223
MODULUS = 36389
FUNCTION_L = lambda x: x**2 - 2*x + 1
def function_H(first_half, second_half):
@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 / 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 / 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:]))
@ehamberg
ehamberg / scatterv.c
Last active January 26, 2025 04:41
MPI_Scatterv example
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define SIZE 4
int main(int argc, char *argv[])
{
int rank, size; // for storing this process' rank, and the number of processes