Skip to content

Instantly share code, notes, and snippets.

View Asinox's full-sized avatar
💭
React + Cinema = App!

Juan Miguel Calcaño Asinox

💭
React + Cinema = App!
View GitHub Profile
@Asinox
Asinox / avatar.js
Last active May 7, 2020 19:22
Asignar avatar
function getAvatar(){
var avatars = ["01","02","03","04","05","06","07","08"];
var rand = Math.floor(Math.random() * avatars.length);
return '//assets.diariolibre.com/img/midl/miDLavatar-'+avatars[rand]+'.png';
}
var tmp_avatar = getAvatar();
function loadUserData(token){
@Asinox
Asinox / WP_filter.php
Last active February 27, 2020 18:40
WP_filter
<?php
query_posts("showposts=40&meta_key=Materia_1&orderby=title&order=DESC");
$coma;
if (have_posts()) : while (have_posts()) : the_post();
$do_not_duplicate = $post->ID;
$materias[] = get_post_meta(get_the_ID(), 'Materia_1', true);
//$found = explode("," , get_post_meta(get_the_ID(), 'Materias', true));
$coma = get_post_meta(get_the_ID(), 'Materias', true);
endwhile;
//$found = array_count_values($materias);
@Asinox
Asinox / gist:de270130cb17ba9bfa9668c7c16a5fe4
Created January 2, 2020 19:10
Fix React Native: Unable to load script.Make sure you are either running a Metro server or that your bundle 'index.android.bundle' is packaged correctly for release
Edit node_modules/metro-config/src/defaults/blacklist.js
Change sharedBlacklist to:
var sharedBlacklist = [
/node_modules[\/\\]react[\/\\]dist[\/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
@Asinox
Asinox / admin.py
Created May 31, 2019 15:11
Filter Django user permissions from admin
"""
Si el usuario pertenece a uno o varios grupos y estos grupos tienen permisos, no muestres estos permisos en el campo para asignar permisos individuales en django admin
"""
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import Group, Permission
class UserAdmin(BaseUserAdmin):
def get_form(self, request, obj=None, **kwargs):
@Asinox
Asinox / localtimezone
Created January 14, 2019 14:15
Apply local timezone to OctoberCMS backend list
public function listOverrideColumnValue($record, $columnName, $definition) {
if ($columnName == 'created_at') {
// apply local timezone
$createdAt = (new \DateTime($record->created_at))->setTimezone(new \DateTimeZone('America/Santo_Domingo'));
return $createdAt->format('d/m/Y g:ia');
}
}
@Asinox
Asinox / recover_file_git
Created January 4, 2019 12:57
How to recover a deleted file from local
git checkout <commit>^ -- <file>
@Asinox
Asinox / ReactNative_Android
Created December 28, 2018 00:46
react-native run-android, Could not install the app on the device
You might check the permissions on android/gradlew
They should be 755 not 644
Run chmod 755 android/gradlew inside your app root folder
then run react-native run-android
@Asinox
Asinox / Swift UIPageControl
Last active August 29, 2015 14:15
Swift version of an Objective-C UIPageControl tutorial (https://www.youtube.com/watch?v=abRCY5St_EM)
//
// WelcomeViewController.swift
//
// Created by Juan Miguel Calcano on 2/2/15.
// Copyright (c) 2015 Juan Miguel Calcano. All rights reserved.
// Swift version of an Objective-C UIPageControl tutorial (https://www.youtube.com/watch?v=abRCY5St_EM)
// UPDATE: swipe UIPageControl
import UIKit
from appx.models import NormalModel, DataMultipleModel
def crearAlgo(request):
form = NormalForm()
formset_data= DataFormset(instance=NormalModel())
if request.method == 'POST':
form = NormalForm(request.POST)
if form.is_valid():
$(function(){
var $targetElement = '.wordBreak';
if($.browser.msie) {
$($targetElement).css('word-break', 'break-all');
} else {
$($targetElement).each(function(){
if(navigator.userAgent.indexOf('Firefox/2') != -1) {
$(this).html($(this).text().split('').join('<wbr />'));
} else {
$(this).html($(this).text().split('').join(String.fromCharCode(8203)));