Skip to content

Instantly share code, notes, and snippets.

View ssz360's full-sized avatar
:octocat:

Seyed Sajjad Zahedi ssz360

:octocat:
View GitHub Profile
@ssz360
ssz360 / Middleware.cs
Created April 25, 2020 06:18
ASP.Net Core: Enable CORS
// from: https://stackoverflow.com/a/45844400/2735163
public class CorsMiddleware
{
private readonly RequestDelegate _next;
public CorsMiddleware(RequestDelegate next)
{
_next = next;
}
@ssz360
ssz360 / main.cs
Created September 25, 2018 11:40
Get screen DPI
var dpiXProperty = typeof(SystemParameters).GetProperty("DpiX", BindingFlags.NonPublic | BindingFlags.Static);
var dpiYProperty = typeof(SystemParameters).GetProperty("Dpi", BindingFlags.NonPublic | BindingFlags.Static);
var dpiX1 = (int)dpiXProperty.GetValue(null, null);
var dpiY2 = (int)dpiYProperty.GetValue(null, null);
System.Windows.Forms.MessageBox.Show(dpiX1 + ":" + dpiY2);
@ssz360
ssz360 / main.cs
Last active September 25, 2018 11:38
making text align without tab (WPF)
public string[][] tabWordsAlign(string[][] array, string delimiter = null, short minimumNumberOfSpaces = 1)
{
for (int i = 0; i < array.Length - 1; i++)
if (array[i].Length != array[i + 1].Length)
throw new Exception("Arrays must be same size");
string[][] result =new string[array.GetLength(0)][];
array.CopyTo(result,0);
@ssz360
ssz360 / ComPort over Network.md
Last active March 12, 2023 18:56 — forked from DraTeots/ComPort over Network.md
ComPort over Network
@ssz360
ssz360 / refresh browser cache.md
Created July 26, 2018 04:27
How to force a browser cache refresh after updating website files
@ssz360
ssz360 / Object.getEffectiveTypeAnnotationNode error.md
Last active April 21, 2020 14:42
How to solve "Module build failed: TypeError: Cannot read property 'type' of undefined at Object.getEffectiveTypeAnnotationNode" of Typescript (angular, ionic, ...)

I could build angular project without problem but when I tired to build with --prod Errors occurred:

Error: ./node_modules/tslib/tslib.es6.js Module build failed: TypeError: Cannot read property 'type' of undefined at Object.getEffectiveTypeAnnotationNode (\node_modules\typescript\lib\typescript.js:9341:18) at assignContextualParameterTypes (\node_modules\typescript\lib\typescript.js:41652:25) at checkFunctionExpressionOrObjectLiteralMethod (\node_modules\typescript\lib\typescript.js:41948:29) at checkExpressionWorker (\node_modules\typescript\lib\typescript.js:42959:28) at checkExpression (\node_modules\typescript\lib\typescript.js:42898:42) at checkBinaryLikeExpression (\node_modules\typescript\lib\typescript.js:42475:29) at checkBinaryExpression (~\node_modules\typescript\lib\typescript.js:42467:20)

@ssz360
ssz360 / angular async pipe.html
Created April 15, 2018 05:09
how to use angular async pipe
<div *ngIf="catalog$ | async as catalog; else loading">
<ng-container *ngIf="catalog.length; else noItems">
<div *ngFor="let item of catalog">{{item.title}}</div>
<ng-container>
<ng-template #noItems>No Items!</ng-template>
</div>
<ng-template #loading>loading animation...</ng-template>
function sb_add_cpts_to_api() {
global $wp_post_types;
// Add CPT slugs here
$arr = ['property','agent'];
foreach( $arr as $key ) {
// If the post type doesn't exist, skip it
if( !$wp_post_types[$key] )
add_action( 'init', 'ssz_rest_api_info', 12 );
function ssz_rest_api_info() {
if ( function_exists( 'register_rest_field' ) ) {
// type or custom type
register_rest_field( "post",
'more_info',
array(
'get_callback' => 'ssz_rest_api_more_info',
@ssz360
ssz360 / wordpress: add more query to rest api requests.php
Last active June 27, 2016 08:51
wordpress: add more query to rest api requests
// wp-json/wp/v2/estate_property?filter[meta_key]=agent&filter[meta_value]=18046
function my_allow_meta_query( $valid_vars ) {
$valid_vars = array_merge( $valid_vars, array( 'meta_key', 'meta_value' ) );
return $valid_vars;
}
add_filter( 'rest_query_vars', 'my_allow_meta_query' );