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
#include <stdint.h> | |
#include <stdio.h> | |
#include <string.h> | |
// returns the sum of all 8 adjacent cells to element [cy][cx] in a 2D array, with bounds checking | |
uint32_t setdata(uint32_t root_max, uint32_t data[][root_max], uint32_t cx, uint32_t cy){ | |
uint32_t counter = 0; | |
if(cx + 1 < root_max){ | |
counter += data[cy][cx+1]; | |
if(cy - 1 >= 0) |
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
import math | |
from PIL import Image, ImageDraw | |
input_image = Image.open("first.png") | |
width,height = input_image.size | |
second_image = Image.new('RGB', input_image.size) | |
third_image = Image.new('RGB', input_image.size) | |
output_image = Image.new('RGB', input_image.size) | |
# draw = ImageDraw.Draw(output_image) |
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
... | |
from OpenSSL import SSL | |
... | |
context = SSL.Context(SSL.TLSv1_2_METHOD) | |
context.use_privatekey_file('/etc/letsencrypt/live/DOMAIN.COM/privkey.pem') | |
context.use_certificate_chain_file('/etc/letsencrypt/live/DOMAIN.COM/fullchain.pem') | |
context.use_certificate_file('/etc/letsencrypt/live/DOMAIN.COM/cert.pem') |
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
g++ -fPIC -c hello.cpp | |
g++ -shared -o hello.so hello.o | |
g++ main.cpp -ldl |
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
std::vector<projectile_t*> projectiles; | |
// ... | |
projectiles.erase( | |
std::remove_if(projectiles.begin(), projectiles.end(), | |
[](projectile_t *p){ return p->life <= 0.0; }), | |
projectiles.end() | |
); |
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
#include <Kit/Window.hpp> | |
#include <Kit/Renderer.hpp> | |
#include <Kit/Quad.hpp> | |
#include <Kit/Light.hpp> // Lights.. | |
#include <Kit/Camera.hpp> // Camera.. | |
#include <Kit/Model.hpp> // Action! | |
int main(int argc, char *argv[]){ |
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
// challenge 277 hard 2016-07-29 /r/dailyprogrammer https://redd.it/4v5h3u | |
// compile: $ gcc -std=c99 challenge277.c -lm | |
// outputs to: fractal.tga | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <math.h> | |
#include <complex.h> |
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
0 0 7 0 0 0 2 2 2 0 0 0 0 0 0 | |
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 | |
0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 | |
0 0 7 0 0 0 2 2 2 0 0 0 0 0 0 | |
0 0 0 0 0 0 0 0 0 2 2 2 0 0 0 | |
2 2 2 0 0 0 0 0 0 0 0 0 2 2 2 |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <math.h> | |
#define PI 3.14159265 | |
// https://www.reddit.com/r/dailyprogrammer/comments/3zfajl/20160104_challenge_248_easy_draw_me_like_one_of/ | |
struct rgb_t { | |
unsigned char r; |
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
import urllib2, json, os, time | |
albumurl = raw_input('imgur album url: ') | |
foldername = albumurl.split('/')[-1].split('#')[0] | |
if not os.path.exists(foldername+'/'): os.mkdir(foldername+'/') | |
print 'downloading html...' | |
albumhtml = urllib2.urlopen(albumurl).read() | |
jdata = '{"count":'+albumhtml.split("{\"count\":")[1].split('\n')[0][:-1] | |
data = json.loads(jdata) | |
print 'going to download',len(data['items']),'images into folder:',foldername |