Skip to content

Instantly share code, notes, and snippets.

View barisusakli's full-sized avatar
🎯
Focusing

Barış Soner Uşaklı barisusakli

🎯
Focusing
View GitHub Profile
class IComponent
{
public:
template<typename T>
static std::shared_ptr<T> get(const std::shared_ptr<Entity>& entity)
{
return std::dynamic_pointer_cast<T>(entity->getComponent(T::Name()));
}
};
@barisusakli
barisusakli / links.js
Created January 18, 2014 04:23
ping links in a topic
@barisusakli
barisusakli / html2canvas to render a html page
Created January 19, 2014 06:30
render url to canvas, not working good enough for general use, uses html2canvas
(function() {
"use strict";
$(document).ready(function() {
$('<iframe frameborder="0" scrolling="no" id="myFrame" width=1024 height=768 class="hidden"></iframe>')
.appendTo('body');
@barisusakli
barisusakli / fix user images to relative
Last active August 29, 2015 13:56
Change absolute user image urls to relative
db.getSortedSetRange('users:joindate', 0, -1, function(err, uids) {
function updateUploadedPicture(uid, next) {
User.getUserFields(uid, ['picture', 'uploadedpicture'], function(err, userData) {
var newPicture = userData.uploadedPicture.replace('http://coinunity.sk', '');
if(userData.uploadedPicture === userData.picture) {
User.setUserField(uid, 'picture', newPicture);
}
@barisusakli
barisusakli / google DFP
Last active December 29, 2015 17:30
google DFP widget ad code
//this goes in <head>
<script type='text/javascript'>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
var gads = document.createElement('script');
gads.async = true;
gads.type = 'text/javascript';
var useSSL = 'https:' == document.location.protocol;
@barisusakli
barisusakli / fontawesome
Last active August 29, 2015 14:02
grab fontawesome icons
var str = '';
$('.fontawesome-icon-list i.fa').each(function() {
if (str.indexOf($(this)[0].outerHTML) === -1 && $(this).parent().html().indexOf('alias') === -1)
str += $(this)[0].outerHTML;
});
console.log(str);
@barisusakli
barisusakli / wrap.js
Last active October 24, 2020 21:05
module wrapper
for (var key in mongoModule) {
// if (mongoModule.hasOwnProperty(key)) {
// saveFunction(key, mongoModule);
// }
// }
// function saveFunction(key, module) {
// if (typeof module[key] === 'function') {
// var oldFn = module[key];
// module[key] = async function (...args) {
@barisusakli
barisusakli / gist:224a7ee8c3be6844687e
Last active August 29, 2015 14:05
fix mainPids in sorted sets
router.get('/fixTopics', function(req, res) {
var db = require('../database'),
async = require('async');
db.getSortedSetRange('topics:tid', 0, -1, function(err, tids) {
function fixTopic(tid, next) {
topics.getTopicField(tid, 'mainPid', function(err, mainPid) {
if (err) {
return next(err);
@barisusakli
barisusakli / sortedembed.js
Created September 11, 2014 05:07
mongodb embedded array
var db = require('../database');
//create index on array score field, and members.value
db.client.collection('test').ensureIndex({"_key": 1, "members.score": 1}, {background:true},function(err) {
console.log(err);
});
// this is basically getSortedSetRange('experiment', 0, 3);
var pipeline = [
{$match: {_key: "experiment"}},
@barisusakli
barisusakli / upvotes.js
Created October 30, 2014 23:40
process all upvotes to a json file
var nconf = require('nconf');
var async = require('async');
var fs = require('fs');
nconf.file({
file: 'config.json'
});