Skip to content

Instantly share code, notes, and snippets.

JavaScript snippets

This gist contains snippets code in JavaScript, one snippet per file. Files here should be name after functions they contain, functions should have short descriptive comments in front of their bodies and the link to there they are taken from (if any) or copyright notice.

Lua snippets

This gist contains snippets code in Lua, one snippet per file. Files here should be name after functions they contain, functions should have short descriptive comments in front of their bodies and the link to there they are taken from (if any) or copyright notice.

/* I'd want this conform to the standard... */
static const char* get_file_basename(const char* full_name) {
const char* fore_slash = strrchr(full_name, '/');
const char* back_slash = strrchr(full_name, '\\');
const char* slash = (fore_slash > back_slash ? fore_slash : back_slash);
return (slash != NULL) ? slash + 1 : full_name;
}
--- Generates the list of summands permutations for given 'sum'.
--- Every permutation is the list of numbers, with length of 'summandsNum';
--- the sum of all items in a permutation equals to 'sum'. Function doesn't
--- generate duplicate permutations, which differ only in order.
summandsPermutations :: Integral a => a -> a -> [[a]]
summandsPermutations summandsNum sum
| summandsNum >= 1 && summandsNum <= sum =
f summandsNum 1 sum
where f n m s
| n==1 && m<=s = [[s]]
// http://wouter.coekaerts.be/2015/puzzle-tweet
class C extends B {
public C() {
super(new java.lang.Long(1));
}
}
class A {
public class B {
#pragma once
#include <memory>
namespace rvlm {
template<typename T>
class object_ptr: public std::shared_ptr<T> {
public:
object_ptr(const object_ptr&) noexcept = default;
#!/bin/bash
# obs-commit-version.sh: update CAF packages on OBS from Jenkins.
# This shell script is created for easy updating CAF binary packages located
# on OpenSUSE Build Service (OBS). It should be issued from the Jenkins after
# release has proven to be operating, like this:
#
# $ make
# $ make test
# $ make doc <-- this is a necessary step!
# $ obs-commit-version.sh --release <-- for release build
@firegurafiku
firegurafiku / temhorn.vb
Created June 11, 2015 13:14
TEM-horn geometry creation script for CST Microwave Studio
' TEMHorn
Option Explicit
Sub Main()
Const MaxPoints = 1000
BeginHide
StoreDoubleParameter "temhorn_which", 0
StoreDoubleParameter "temhorn_points", 30
// Coompilation:
// g++ -I/usr/include/eigen3 -O3 -march=native -fopenmp -o test-eigen-lu test-eigen-lu.cpp
//
// Run:
// export OMP_NUM_THREADS=N ; time ./test-eigen-lu
//#include <iostream>
#include <Eigen/Dense>
#include <Eigen/Core>
using namespace std;
struct rfdtd_error_info
function(T arg1, T arg2) {
struct rfdtd_error_info error = RFDTD_NO_ERROR;
CHECK(function(arg1, &arg2));
CHECK(another_function());
CHECK(one_more_of_them());
CHECK(rfdtd_new(&ptr));
ON_ERROR(function)