Skip to content

Instantly share code, notes, and snippets.

View Adamkaram's full-sized avatar
🏠
Working from home

AhmedKaram Adamkaram

🏠
Working from home
View GitHub Profile
@Adamkaram
Adamkaram / underscore.mixin.deepExtend.coffee
Created November 28, 2020 23:55 — forked from ElliotChong/underscore.mixin.deepExtend.coffee
Copy all of the properties in the source objects over to the destination object, and return the destination object. This method will recursively copy mutual properties which are also objects.
# Create a deep copy of an object. - CoffeeScript conversion of @cederberg's deepClone implementation https://github.com/documentcloud/underscore/pull/595
deepClone = (obj) ->
if !_.isObject(obj) or _.isFunction(obj) then return obj
if _.isDate obj then return new Date do obj.getTime
if _.isRegExp obj then return new RegExp obj.source, obj.toString().replace(/.*\//, "")
isArr = _.isArray obj or _.isArguments obj
func = (memo, value, key) ->
if isArr then memo.push deepClone value
@Adamkaram
Adamkaram / App.js
Created November 14, 2020 02:11 — forked from shelldandy/App.js
nprogress with react-router in create-react-app
import React from 'react'
import { BrowserRouter as Router, Switch } from 'react-router-dom'
import routes from './routes'
import FancyRoute from './components/tools/FancyRoute'
const App = props =>
<Router>
<Switch>
{routes.map((route, i) =>
<FancyRoute key={i} {...route} />
@Adamkaram
Adamkaram / App.js
Created November 14, 2020 02:11 — forked from shelldandy/App.js
nprogress with react-router in create-react-app
import React from 'react'
import { BrowserRouter as Router, Switch } from 'react-router-dom'
import routes from './routes'
import FancyRoute from './components/tools/FancyRoute'
const App = props =>
<Router>
<Switch>
{routes.map((route, i) =>
<FancyRoute key={i} {...route} />
@Adamkaram
Adamkaram / App.js
Created November 14, 2020 02:11 — forked from shelldandy/App.js
nprogress with react-router in create-react-app
import React from 'react'
import { BrowserRouter as Router, Switch } from 'react-router-dom'
import routes from './routes'
import FancyRoute from './components/tools/FancyRoute'
const App = props =>
<Router>
<Switch>
{routes.map((route, i) =>
<FancyRoute key={i} {...route} />
@Adamkaram
Adamkaram / validate_enum.go
Created September 24, 2020 01:28 — forked from ElegantSoft/validate_enum.go
Use enum validation in golang with gin with custom error messages
// user model
type User struct {
gorm.Model
Name string `json:"name" binding:"required" gorm:"not null:true"`
Phone string `json:"phone" binding:"required"`
Email string `json:"email" binding:"required,email" gorm:"not null:true"`
Password string `json:"password" binding:"required,min=8" gorm:"not null:true"`
Gender string `json:"gender" binding:"Enum=male_female" gorm:"type:gender;not null:true;default:male"` // add binding Enum=male_female
}
@Adamkaram
Adamkaram / validate_enum.go
Created September 24, 2020 01:28 — forked from ElegantSoft/validate_enum.go
Use enum validation in golang with gin with custom error messages
// user model
type User struct {
gorm.Model
Name string `json:"name" binding:"required" gorm:"not null:true"`
Phone string `json:"phone" binding:"required"`
Email string `json:"email" binding:"required,email" gorm:"not null:true"`
Password string `json:"password" binding:"required,min=8" gorm:"not null:true"`
Gender string `json:"gender" binding:"Enum=male_female" gorm:"type:gender;not null:true;default:male"` // add binding Enum=male_female
}