Skip to content

Instantly share code, notes, and snippets.

@ioannisa
ioannisa / Jetpack Compose - RecyclerView with Sticky Headers - MainActivity.kt
Last active February 4, 2023 09:06
Jetpack Compose RecyclerView with Sticky Header and network images using Coil
package eu.anifantakis.composeapp
import android.os.Bundle
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.*
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
@yousufansa
yousufansa / functions.php
Created November 1, 2019 05:58
Jobhunt - Set Login Form as Default Tab
if ( ! function_exists( 'jobhunt_register_login_form' ) ) {
function jobhunt_register_login_form() {
$output = '';
if( ! is_user_logged_in() ) {
ob_start();
?>
<div class="jobhunt-register-login-form">
<div class="jobhunt-register-login-form-inner">
add_action( 'init', 'bf_register_custom_post_type' );
/**
* Registro un custom post type 'libro'.
*
* @link http://codex.wordpress.org/Function_Reference/register_post_type
*/
function bf_register_custom_post_type() {
/* Añado las etiquetas que aparecerán en el escritorio de WordPress */
$labels = array(
'name' => _x( 'Libros', 'post type general name', 'text-domain' ),
@KalpeshTalkar
KalpeshTalkar / Validator.kt
Last active October 2, 2022 09:42
A validator class written in Kotlin can be used to validate the data. Eg. checks for valid email, phone, password, name, etc.
//
// Copyright © 2018 Kalpesh Talkar. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@algal
algal / ScaleAspectFitImageView.swift
Last active September 24, 2023 10:19
UIImageView subclass that works with Auto Layout to express its desired aspect ratio
import UIKit
// known-good: Xcode 8.2.1
/**
UIImageView subclass which works with Auto Layout to try
to maintain the same aspect ratio as the image it displays.
This is unlike the usual behavior of UIImageView, where the
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<style type="text/css">
#overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000;
filter:alpha(opacity=70);
// 1
protocol Hablar {
func decirHola(nombre: String)
}
// 2
class Persona: Hablar {
// 3
func decirHola(nombre: String) {
// 4
@yoren
yoren / functions.php
Last active September 14, 2022 21:02
Add Featured Image Thumbnail URL to wp-json/wp/v2/posts Endpoint
<?php
function my_rest_prepare_post( $data, $post, $request ) {
$_data = $data->data;
$thumbnail_id = get_post_thumbnail_id( $post->ID );
$thumbnail = wp_get_attachment_image_src( $thumbnail_id );
$_data['featured_image_thumbnail_url'] = $thumbnail[0];
$data->data = $_data;
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let urlPath = "http://telize.com/geoip"
let url = NSURL(string: urlPath)
let session = NSURLSession.sharedSession()
let task = session.dataTaskWithURL(url!, completionHandler: {data, response, error -> Void in
@aliciaduffy
aliciaduffy / gist:3362670
Last active May 12, 2022 03:49
WordPress / ADMIN / Remove meta boxes from post edit screen
<?php
add_action( 'add_meta_boxes', 'NAME_remove_meta_boxes', 100);
function NAME_remove_meta_boxes() {
remove_meta_box( 'trackbacksdiv', 'post', 'normal' ); // Trackbacks meta box
remove_meta_box( 'postcustom', 'post', 'normal' ); // Custom fields meta box
remove_meta_box( 'commentsdiv', 'post', 'normal' ); // Comments meta box
remove_meta_box( 'slugdiv', 'post', 'normal' ); // Slug meta box
remove_meta_box( 'authordiv', 'post', 'normal' ); // Author meta box
remove_meta_box( 'revisionsdiv', 'post', 'normal' ); // Revisions meta box
remove_meta_box( 'formatdiv', 'post', 'normal' ); // Post format meta box