Skip to content

Instantly share code, notes, and snippets.

View 345161974's full-sized avatar
🎯
Focusing

Lucas 345161974

🎯
Focusing
View GitHub Profile
@hainm
hainm / test.pyx
Last active March 27, 2017 08:35
test.pyx
# distutils: language = c++
cdef cppclass A:
void c_test():
print ("hello from A")
cdef cppclass B(A):
void SetObject(A* ptr):
print ("dummy method, hello from B")
cdef class pyA:
@stlehmann
stlehmann / setup.py
Created January 13, 2015 12:45
py2exe setup script for PyQt5 application including matplotlib, numpy, scipy, pandas
#! python3.4
from setuptools import setup
import os
import py2exe
import matplotlib
includes = ["sip",
"PyQt5",
"PyQt5.QtCore",
"PyQt5.QtGui",
@mgronhol
mgronhol / fast-str.c
Last active October 23, 2024 16:28
Fast string compare
int fast_compare( const char *ptr0, const char *ptr1, int len ){
int fast = len/sizeof(size_t) + 1;
int offset = (fast-1)*sizeof(size_t);
int current_block = 0;
if( len <= sizeof(size_t)){ fast = 0; }
size_t *lptr0 = (size_t*)ptr0;
size_t *lptr1 = (size_t*)ptr1;
@sheharyarn
sheharyarn / mongo_backup.sh
Last active December 12, 2024 15:16
Mongodump Shell Script for Cronjob
#!/bin/bash
MONGO_DATABASE="your_db_name"
APP_NAME="your_app_name"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/username/backups/$APP_NAME"
@friendzis
friendzis / TimePlot.py
Created May 7, 2014 11:19
Simple implementation of TimeAxisItem and test program
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
from PySide.QtCore import QTime, QTimer
from collections import deque
t = QTime()
t.start()
data = deque(maxlen=20)
@diabloneo
diabloneo / timespec_diff.c
Created March 18, 2014 13:22
Calculate diff of two struct timespec
#include <time.h>
void timespec_diff(struct timespec *start, struct timespec *stop,
struct timespec *result)
{
if ((stop->tv_nsec - start->tv_nsec) < 0) {
result->tv_sec = stop->tv_sec - start->tv_sec - 1;
result->tv_nsec = stop->tv_nsec - start->tv_nsec + 1000000000;
} else {
result->tv_sec = stop->tv_sec - start->tv_sec;
@kjprince
kjprince / Wordpress Nginx Config
Last active April 14, 2021 17:31
/etc/nginx/wordpress.conf
##################################
# WORDPRESS NGINX CONFIGURATIONS
##################################
# /etc/nginx/wordpress.conf
#
# Contains a common configuration for use by nginx on a WordPress
# installation. This file should be included in any WordPress site
# nginx virtual host config located in sites-available with the following line:
#
# include /etc/nginx/wordpress.config;
@ardan-bkennedy
ardan-bkennedy / GoMgoSample-1.go
Last active January 31, 2025 09:00
Sample Go and MGO example
type (
// BuoyCondition contains information for an individual station.
BuoyCondition struct {
WindSpeed float64 `bson:"wind_speed_milehour"`
WindDirection int `bson:"wind_direction_degnorth"`
WindGust float64 `bson:"gust_wind_speed_milehour"`
}
// BuoyLocation contains the buoy's location.
BuoyLocation struct {
@osimola
osimola / prefetch_example.c
Created December 11, 2013 20:11
Example of __builtin_prefetch() in action.
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <time.h>
const size_t memsize = 128 * 1024 * 1024;
const size_t elems = memsize / sizeof(uint32_t);
void shuffle(uint32_t* data, size_t elems);
void time_linear(const uint32_t* indices, size_t elems);
@waqasjamal-zz
waqasjamal-zz / gist:7428185
Last active February 22, 2021 19:37
Python Code for adding posts to WordPress remotely
import urllib
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods import posts
import xmlrpclib
from wordpress_xmlrpc.compat import xmlrpc_client
from wordpress_xmlrpc.methods import media, posts
import os
########################### Read Me First ###############################
'''
------------------------------------------In DETAIL--------------------------------