Skip to content

Instantly share code, notes, and snippets.

View jeandudey's full-sized avatar
🦅

Jean-Pierre De Jesus DIAZ jeandudey

🦅
View GitHub Profile
void Text::glRenderText(std::string text, TTF_Font *font, SDL_Color color, SDL_Rect *location)
{
int w,
h;
SDL_Surface *FontSurface;
GLuint TextureID;
FontSurface = TTF_RenderText_Blended(font, text.c_str(), color);
@jeandudey
jeandudey / README.md
Last active December 4, 2017 16:47
My git commit template.

Template for Git

To use this template just paste all of this (crap) in your terminal or set the correct options for git:

cd ~/
wget https://gist.github.com/jeandudey/34bfd30d2668fb572449/raw/6bcebe9d843aff6d0a5d130d0a6ea327f80f1afd/template -O .gctemplate
git config --global commit.template ~/.gctemplate
@jeandudey
jeandudey / Main.cc
Created July 14, 2015 14:11
Is even or odd in C++ template metaprogramming.
#include <iostream>
template <int a>
struct isodd {
static constexpr bool value = a % 2;
};
template <int a>
struct iseven {
static constexpr bool value = !(a % 2);
@jeandudey
jeandudey / Main.cc
Created July 25, 2015 14:48
Backward Text on C++.
#include <iostream>
#include <fstream>
#include <string>
int main(int argc, char **argv)
{
std::ifstream file("HelloWorld.txt");
std::string words;
if (file.is_open()) {
@jeandudey
jeandudey / UAGS.cc
Created July 27, 2015 15:49
Universal Acronym Generating System [/r/programmingprompts]
#include <iostream>
#include <sstream>
#include <string>
#include <locale>
#define MAX_WORDS 20
std::string acronymise(std::string str)
{
std::string words[MAX_WORDS];
@jeandudey
jeandudey / README.md
Last active August 29, 2015 14:25
Can i wrap argc and argv to an object in C++?

Can i wrap argc and argv to an object in C++?

Lets say you're a purist object oriented programmer and you want wrap the argc and argv constant variables in a more situable container like std::vector and don't know how?

Here is the pre-canned solution just for you (licensed under the [WTFPL][1]):

// File: ArgumentsList.hpp
typedef std::vector<std::string> ArgumentsList;

void fill_arguments(ArgumentsList &amp;args, int argc, const char **argv)
@jeandudey
jeandudey / literalstring.py
Created August 10, 2015 21:04
String to char literals (to use it with PEGTL).
#!/usr/bin/python3
# Description: convert an string to a "literal string" (i.e. 'H', 'e', 'l', 'l', 'o')
# to use in PEGTL (i.e pegtl::string< 'H', 'e', 'l', 'l', 'o', ',', ' ' >).
def toliteralstring(str):
result = ""
for c in str:
result += "'" + c "' "
@jeandudey
jeandudey / copy-dlls.py
Created August 16, 2015 14:46
Copy list of DLL files to the runtime directory (build).
#!/usr/bin/python3
import shutil
# Description: copy list of dlls to the given directory.
DLLS = ["libglibmm-2.4-1.dll",
"libgtkmm-3.0-1.dll",
"libgobject-2.0-0.dll",
"libglib-2.0-0.dll",
@jeandudey
jeandudey / main.c
Created December 27, 2015 13:52
GTK borderless window
#include <stdio.h>
#include <gtk/gtk.h>
void hello(GtkWidget* widget, gpointer data)
{
printf("Hello World!\n");
}
int main(int argc, char* argv[])
{
impl<'a> std::ops::Sub<Vec3> for &'a Vec3 {
type Output = Vec3;
fn sub(self, other: Vec3) -> Vec3 {
let mut output = Vec3::new([0f64; 3]);
for index in 0..3 {
output.vector[index] = self.vector[index] - other.vector[index];
}
return output;
}
}