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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- 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]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://wouter.coekaerts.be/2015/puzzle-tweet | |
class C extends B { | |
public C() { | |
super(new java.lang.Long(1)); | |
} | |
} | |
class A { | |
public class B { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' TEMHorn | |
Option Explicit | |
Sub Main() | |
Const MaxPoints = 1000 | |
BeginHide | |
StoreDoubleParameter "temhorn_which", 0 | |
StoreDoubleParameter "temhorn_points", 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
OlderNewer